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.