public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100822] New: new expression for an array of function pointers gets parsed as lambda incorrectly
@ 2021-05-28 20:57 lfppgg at supersave dot net
  2022-11-02  0:26 ` [Bug c++/100822] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: lfppgg at supersave dot net @ 2021-05-28 20:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100822

            Bug ID: 100822
           Summary: new expression for an array of function pointers gets
                    parsed as lambda incorrectly
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lfppgg at supersave dot net
  Target Milestone: ---

Created attachment 50888
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50888&action=edit
preprocessed source

$ gcc -v -save-temps main.cpp
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--enable-default-pie --enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id
--enable-lto --enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-mtune=generic' '-march=x86-64'
'-dumpdir' 'a-'
 /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/cc1plus -E -quiet -v -D_GNU_SOURCE
main.cpp -mtune=generic -march=x86-64 -fpch-preprocess -o a-main.ii
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0

/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/x86_64-pc-linux-gnu

/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0/backward
 /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include
 /usr/local/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-mtune=generic' '-march=x86-64'
'-dumpdir' 'a-'
 /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/cc1plus -fpreprocessed a-main.ii
-quiet -dumpdir a- -dumpbase main.cpp -dumpbase-ext .cpp -mtune=generic
-march=x86-64 -version -o a-main.s
GNU C++17 (GCC) version 11.1.0 (x86_64-pc-linux-gnu)
        compiled by GNU C version 11.1.0, GMP version 6.2.1, MPFR version
4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++17 (GCC) version 11.1.0 (x86_64-pc-linux-gnu)
        compiled by GNU C version 11.1.0, GMP version 6.2.1, MPFR version
4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 45eb9a71cc15bfdc579557bea4b77e51
main.cpp: In function ‘int main()’:
main.cpp:5:23: warning: capture of variable ‘N’ with non-automatic storage
duration
    5 |     f = new (double(*[N])(double, double*));
      |                       ^
main.cpp:1:15: note: ‘constexpr const int N’ declared here
    1 | constexpr int N = 10;
      |               ^
main.cpp: In lambda function:
main.cpp:5:25: error: expected ‘{’ before ‘)’ token
    5 |     f = new (double(*[N])(double, double*));
      |                         ^
main.cpp: In function ‘int main()’:
main.cpp:5:14: error: invalid cast from type ‘void (*)()’ to type ‘double’
    5 |     f = new (double(*[N])(double, double*));
      |              ^~~~~~~~~~~~
main.cpp:5:20: error: expected ‘)’ before ‘(’ token
    5 |     f = new (double(*[N])(double, double*));
      |             ~      ^
      |                    )
main.cpp:5:22: error: cannot convert ‘void (*)()’ to ‘double’ in initialization
    5 |     f = new (double(*[N])(double, double*));
      |                      ^
      |                      |
      |                      void (*)()



If you replace N with integer literal, the code compiles without errors.
Therefore I suppose it might be a bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/100822] new expression for an array of function pointers gets parsed as lambda incorrectly
  2021-05-28 20:57 [Bug c++/100822] New: new expression for an array of function pointers gets parsed as lambda incorrectly lfppgg at supersave dot net
@ 2022-11-02  0:26 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-02  0:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100822

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
           Keywords|                            |c++-lambda
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-11-02

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-02  0:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28 20:57 [Bug c++/100822] New: new expression for an array of function pointers gets parsed as lambda incorrectly lfppgg at supersave dot net
2022-11-02  0:26 ` [Bug c++/100822] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).