https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118287
Bug ID: 118287 Summary: [concepts] Concept with lambda non-type param causes ICE Product: gcc Version: 14.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: james.antony.brown at gmail dot com Target Milestone: --- Replicated on https://godbolt.org/z/3EfT4o6n5 Gcc 14.1, 14.2, and trunk have an ICE compiling this. Gcc 11 - 13 all reject the code. I'd guess the code is valid C++, but I am not confident on that. This is possibly related to 102047 or 117034 ==== Code ==== template<typename, auto> concept WithNonTypeParam = [] { return true; }(); template<typename Type> concept WithLambda = WithNonTypeParam<Type, [](auto) { }>; template<typename> WithLambda auto get() { return 0; } int main() { get<int>(); } ==== Local Machine ==== (Windows 11 machine, GCC 14.2) g++ -v --save-temps -std=gnu++23 crash.ii Using built-in specs. COLLECT_GCC=C:\Program Files\MinGW\MinGW-14.2.0\mingw64\bin\g++.exe COLLECT_LTO_WRAPPER=C:/Program\ Files/MinGW/MinGW-14.2.0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/14.2.0/lto-wrapper.exe OFFLOAD_TARGET_NAMES=nvptx-none Target: x86_64-w64-mingw32 Configured with: ../configure --prefix=/R/winlibs64ucrt_stage/inst_gcc-14.2.0/share/gcc --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --enable-offload-targets=nvptx-none --with-pkgversion='MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r1' --with-tune=generic --enable-checking=release --enable-threads=posix --disable-sjlj-exceptions --disable-libunwind-exceptions --disable-serial-configure --disable-bootstrap --enable-host-shared --enable-plugin --disable-default-ssp --disable-rpath --disable-libstdcxx-debug --disable-version-specific-runtime-libs --with-stabs --disable-symvers --enable-languages=c,c++,fortran,lto,objc,obj-c++ --disable-gold --disable-nls --disable-stage1-checking --disable-win32-registry --disable-multilib --enable-ld --enable-libquadmath --enable-libada --enable-libssp --enable-libstdcxx --enable-lto --enable-fully-dynamic-string --enable-libgomp --enable-graphite --enable-mingw-wildcard --enable-libstdcxx-time --enable-libstdcxx-pch --with-mpc=/d/Prog/winlibs64ucrt_stage/custombuilt --with-mpfr=/d/Prog/winlibs64ucrt_stage/custombuilt --with-gmp=/d/Prog/winlibs64ucrt_stage/custombuilt --with-isl=/d/Prog/winlibs64ucrt_stage/custombuilt --disable-libstdcxx-backtrace --enable-install-libiberty --enable-__cxa_atexit --without-included-gettext --with-diagnostics-color=auto --enable-clocale=generic --with-libiconv --with-system-zlib --with-build-sysroot=/R/winlibs64ucrt_stage/gcc-14.2.0/build_mingw/mingw-w64 CFLAGS='-D__USE_MINGW_ANSI_STDIO=0 -I/d/Prog/winlibs64ucrt_stage/custombuilt/include/libdl-win32 -march=nocona -msahf -mtune=generic -O2 -Wno-error=format' CXXFLAGS='-D__USE_MINGW_ANSI_STDIO=0 -Wno-int-conversion -march=nocona -msahf -mtune=generic -O2' LDFLAGS='-pthread -Wl,--no-insert-timestamp -Wl,--dynamicbase -Wl,--high-entropy-va -Wl,--nxcompat -Wl,--tsaware' LD=/d/Prog/winlibs64ucrt_stage/custombuilt/share/binutils/bin/ld.exe Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 14.2.0 (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r1) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=gnu++23' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-' C:/Program Files/MinGW/MinGW-14.2.0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/14.2.0/cc1plus.exe -fpreprocessed crash.ii -quiet -dumpdir a- -dumpbase crash.ii -dumpbase-ext .ii -mtune=generic -march=x86-64 -std=gnu++23 -version -o a-crash.s GNU C++23 (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r1) version 14.2.0 (x86_64-w64-mingw32) compiled by GNU C version 14.2.0, GMP version 6.3.0, MPFR version 4.2.1, MPC version 1.3.1, isl version isl-0.26-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: ebb6c4cc1bfd77c50a973da944046a55 crash.ii: In instantiation of 'auto [requires ::WithLambda<<placeholder>, >] get() [with <template-parameter-1-1> = int ': crash.ii:13:13: required from here 13 | get<int>(); | ~~~~~~~~^~ crash.ii:5:45: internal compiler error: Segmentation fault 5 | concept WithLambda = WithNonTypeParam<Type, [](auto) { }>; | ^~~~~~~~~~~~ Please submit a full bug report, with preprocessed source (by using -freport-bug). See <https://gcc.gnu.org/bugs/> for instructions. ==== Godbolt Trunk ==== (From Godbolt trunk https://godbolt.org/z/3EfT4o6n5, 14.x has the same trace minus the line numbers and fancy abort) <source>: In instantiation of 'auto [requires ::WithLambda<<placeholder>, >] get() [with <template-parameter-1-1> = int]': <source>:13:13: required from here 13 | get<int>(); | ~~~~~~~~^~ <source>:5:45: internal compiler error: in add_extra_args, at cp/pt.cc:13737 5 | concept WithLambda = WithNonTypeParam<Type, [](auto) { }>; | ^~~~~~~~~~~~ 0x2937ea5 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x294eca6 internal_error(char const*, ...) ???:0 0xacb070 fancy_abort(char const*, int, char const*) ???:0 0xd1765d tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*) ???:0 0xd281c1 tsubst_template_arg(tree_node*, tree_node*, int, tree_node*) ???:0 0xb519b8 constraints_satisfied_p(tree_node*, tree_node*) ???:0 0xd055fc do_auto_deduction(tree_node*, tree_node*, tree_node*, int, auto_deduction_context, tree_node*, int, tree_node*) ???:0 0xdbe075 check_return_expr(tree_node*, bool*, bool*) ???:0 0xd5fb68 finish_return_stmt(tree_node*) ???:0 0xd0f82d instantiate_decl(tree_node*, bool, bool) ???:0 0xbcde13 maybe_instantiate_decl(tree_node*) ???:0 0xbcfac7 mark_used(tree_node*, int) ???:0 0xb0101e build_new_function_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int) ???:0 0xd65676 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, bool, int) ???:0 0xce560a c_parse_file() ???:0 0xe44eb9 c_common_parse_file() ???:0 Please submit a full bug report, with preprocessed source. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. Preprocessed source stored into /tmp/ccdpfiJq.out file, please attach this to your bugreport. Compiler returned: 1