https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121328
Bug ID: 121328 Summary: ICE: Segmentation fault on local lambda constraints with pack expression Product: gcc Version: 15.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rextse.work at gmail dot com Target Milestone: --- Created attachment 62015 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62015&action=edit preprocessed compile target Compiler dump when target is compiled with "g++-15 -std=c++23 bug.cpp -freport-bug": bug.cpp: In substitution of ‘template<class N> f<number<1>, number<2>, number<3> >(number<1>, number<2>, number<3>)::<lambda(N)> [with N = number<6>]’: bug.cpp:22:45: required from here 22 | f(number<1>{}, number<2>{}, number<3>{})(number<6>{}); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~ bug.cpp:17:27: internal compiler error: Segmentation fault 17 | using T = decltype(sum(ns...)); | ~~~^~~~~~~ 0x16ad25d internal_error(char const*, ...) ../../src/gcc/diagnostic-global-context.cc:517 0x1090031 crash_signal ../../src/gcc/toplev.cc:322 0x73e5d74458cf ??? ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 0x181eadb hash_table<hash_map<tree_node*, tree_node*, simple_hashmap_traits<default_hash_traits<tree_node*>, tree_node*> >::hash_entry, false, xcallocator>::find_slot_with_hash(tree_node* const&, unsigned int, insert_option) ../../src/gcc/hash-table.h:1039 0x1ac1ff1 hash_map<tree_node*, tree_node*, simple_hashmap_traits<default_hash_traits<tree_node*>, tree_node*> >::put(tree_node* const&, tree_node* const&) ../../src/gcc/hash-map.h:170 0x1ac1ff1 register_local_specialization(tree_node*, tree_node*) ../../src/gcc/cp/pt.cc:2012 0x19eb8ba gen_elem_of_pack_expansion_instantiation ../../src/gcc/cp/pt.cc:13277 0x19eb8ba tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.cc:14031 0x1a53648 tsubst_call_args ../../src/gcc/cp/pt.cc:20486 0x197c095 tsubst_expr(tree_node*, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.cc:21337 0x192e0af tsubst(tree_node*, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.cc:17221 0x1a37970 tsubst_scope ../../src/gcc/cp/pt.cc:17302 0x1a37970 tsubst_qualified_id ../../src/gcc/cp/pt.cc:17578 0x197c240 tsubst_expr(tree_node*, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.cc:20937 0x197cb87 tsubst_expr(tree_node*, tree_node*, int, tree_node*) ../../src/gcc/cp/pt.cc:20890 0xf2a4e9 satisfy_atom ../../src/gcc/cp/constraint.cc:2430 0xf2a4e9 satisfy_constraint_r ../../src/gcc/cp/constraint.cc:2495 0xf2a75e satisfy_normalized_constraints ../../src/gcc/cp/constraint.cc:2520 0xf2a972 satisfy_declaration_constraints ../../src/gcc/cp/constraint.cc:2742 0xf2a972 constraint_satisfaction_value ../../src/gcc/cp/constraint.cc:2763 Please submit a full bug report, with preprocessed source. Please include the complete backtrace with any bug report. See <file:///usr/share/doc/gcc-15/README.Bugs> for instructions. === BEGIN GCC DUMP === 29047: // Target: x86_64-linux-gnu 29047: // Configured with: ../src/configure -v --with-pkgversion='Ubuntu 15.1.0-1ubuntu0.1' --with-bugurl=file:///usr/share/doc/gcc-15/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust,cobol,algol68 --prefix=/usr --with-gcc-major-version-only --program-suffix=-15 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-15-aT1mMg/gcc-15-15.1.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-15-aT1mMg/gcc-15-15.1.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2 29047: // Thread model: posix 29047: // Supported LTO compression algorithms: zlib zstd 29047: // gcc version 15.1.0 (Ubuntu 15.1.0-1ubuntu0.1) 29047: // 29047: // bug.cpp: In substitution of ‘template<class N> f<number<1>, number<2>, number<3> >(number<1>, number<2>, number<3>)::<lambda(N)> [with N = number<6>]’: 29047: // bug.cpp:22:45: required from here 29047: // 22 | f(number<1>{}, number<2>{}, number<3>{})(number<6>{}); 29047: // | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~ 29047: // bug.cpp:17:27: internal compiler error: Segmentation fault 29047: // 17 | using T = decltype(sum(ns...)); 29047: // | ~~~^~~~~~~ 29047: // 0x16ad25d internal_error(char const*, ...) 29047: // ../../src/gcc/diagnostic-global-context.cc:517 29047: // 0x1090031 crash_signal 29047: // ../../src/gcc/toplev.cc:322 29047: // 0x7ffff78458cf ??? 29047: // ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 29047: // 0x181eadb hash_table<hash_map<tree_node*, tree_node*, simple_hashmap_traits<default_hash_traits<tree_node*>, tree_node*> >::hash_entry, false, xcallocator>::find_slot_with_hash(tree_node* const&, unsigned int, insert_option) 29047: // ../../src/gcc/hash-table.h:1039 29047: // 0x1ac1ff1 hash_map<tree_node*, tree_node*, simple_hashmap_traits<default_hash_traits<tree_node*>, tree_node*> >::put(tree_node* const&, tree_node* const&) 29047: // ../../src/gcc/hash-map.h:170 29047: // 0x1ac1ff1 register_local_specialization(tree_node*, tree_node*) 29047: // ../../src/gcc/cp/pt.cc:2012 29047: // 0x19eb8ba gen_elem_of_pack_expansion_instantiation 29047: // ../../src/gcc/cp/pt.cc:13277 29047: // 0x19eb8ba tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*) 29047: // ../../src/gcc/cp/pt.cc:14031 29047: // 0x1a53648 tsubst_call_args 29047: // ../../src/gcc/cp/pt.cc:20486 29047: // 0x197c095 tsubst_expr(tree_node*, tree_node*, int, tree_node*) 29047: // ../../src/gcc/cp/pt.cc:21337 29047: // 0x192e0af tsubst(tree_node*, tree_node*, int, tree_node*) 29047: // ../../src/gcc/cp/pt.cc:17221 29047: // 0x1a37970 tsubst_scope 29047: // ../../src/gcc/cp/pt.cc:17302 29047: // 0x1a37970 tsubst_qualified_id 29047: // ../../src/gcc/cp/pt.cc:17578 29047: // 0x197c240 tsubst_expr(tree_node*, tree_node*, int, tree_node*) 29047: // ../../src/gcc/cp/pt.cc:20937 29047: // 0x197cb87 tsubst_expr(tree_node*, tree_node*, int, tree_node*) 29047: // ../../src/gcc/cp/pt.cc:20890 29047: // 0xf2a4e9 satisfy_atom 29047: // ../../src/gcc/cp/constraint.cc:2430 29047: // 0xf2a4e9 satisfy_constraint_r 29047: // ../../src/gcc/cp/constraint.cc:2495 29047: // 0xf2a75e satisfy_normalized_constraints 29047: // ../../src/gcc/cp/constraint.cc:2520 29047: // 0xf2a972 satisfy_declaration_constraints 29047: // ../../src/gcc/cp/constraint.cc:2742 29047: // 0xf2a972 constraint_satisfaction_value 29047: // ../../src/gcc/cp/constraint.cc:2763 29047: // Please submit a full bug report, with preprocessed source. 29047: // Please include the complete backtrace with any bug report. 29047: // See <file:///usr/share/doc/gcc-15/README.Bugs> for instructions. 29047: 29047: // /usr/libexec/gcc/x86_64-linux-gnu/15/cc1plus -quiet -imultiarch x86_64-linux-gnu -D_GNU_SOURCE bug.cpp -quiet -dumpdir a- -dumpbase bug.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -std=c++23 -freport-bug -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -fcf-protection -o - -frandom-seed=0 -fdump-noaddr 29047: 29047: # 0 "bug.cpp" 29047: # 0 "<built-in>" 29047: # 0 "<command-line>" 29047: # 1 "/usr/include/stdc-predef.h" 1 3 4 29047: # 0 "<command-line>" 2 29047: # 1 "bug.cpp" 29047: template <int N> 29047: struct number { 29047: static constexpr int n = N; 29047: }; 29047: 29047: template <typename N, typename... Ns> 29047: auto sum(N n, Ns... ns) { 29047: if constexpr (sizeof...(Ns) == 0) { 29047: return N{}; 29047: } else { 29047: return number<N::n + decltype(sum(ns...))::n>{}; 29047: } 29047: } 29047: 29047: template <typename... Ns> 29047: auto f(Ns... ns) { 29047: using T = decltype(sum(ns...)); 29047: return []<typename N>(N n) requires(N::n == T::n) {}; 29047: } 29047: 29047: int main() { 29047: f(number<1>{}, number<2>{}, number<3>{})(number<6>{}); 29047: } === END GCC DUMP === Note: The code should compile (tested on Clang).