https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115930
Bug ID: 115930 Summary: ICE: tree check: expected type_argument_pack or nontype_argument_pack, have integer_type in template_parm_natural_p, at cp/mangle.cc:1828 Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: iamanonymous.cs at gmail dot com Target Milestone: --- Target: x86_64 ******************************************************************************* The compiler produces an internal error during tree_check_failed when compiling the provided code with the specified options. The issue can also be reproduced on Compiler Explorer. ******************************************************************************* OS and Platform: # uname -a Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux ******************************************************************************* # g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/root/gdbtest/gcc/gcc-15/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /root/gdbtest/gcc/obj/../gcc/configure --prefix=/root/gdbtest/gcc/gcc-15 --enable-languages=c,c++,fortran,go --disable-multilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 15.0.0 20240509 (experimental) (GCC) ******************************************************************************* Program: # cat source_code_1.cpp #include <iostream> template <auto... Refs> struct MemPtrList {}; struct X { int a; }; template <typename T> int bar () { std::cout << "bar" << std::endl; return 42; } template <typename... SubPtrTypes, SubPtrTypes X::*...SubRefs> void foo (MemPtrList<SubRefs...>) { // Version 1 (miscompile) int dummy [] = { bar<SubPtrTypes> () ... }; // Version 2 (ICE) // (bar<SubPtrTypes> (), ...); } int main () { foo (MemPtrList<&X::a> {}); } ******************************************************************************* Command Lines: # g++ source_code_1.cpp -O2 -Wall -Wextra -pedantic -std=c++20 -fno-exceptions -fno-rtti -fstrict-aliasing -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Woverloaded-virtual -Wconversion -Wsign-conversion -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wuseless-cast -Wdouble-promotion -Wformat=2 -fconcepts-diagnostics-depth=2 -o source_code_1.o source_code_1.cpp: In function ‘int bar()’: source_code_1.cpp:11:14: error: ‘cout’ is not a member of ‘std’ 11 | std::cout << "bar" << std::endl; | ^~~~ source_code_1.cpp:1:1: note: ‘std::cout’ is defined in header ‘<iostream>’; this is probably fixable by adding ‘#include <iostream>’ +++ |+#include <iostream> 1 | source_code_1.cpp:11:36: error: ‘endl’ is not a member of ‘std’ 11 | std::cout << "bar" << std::endl; | ^~~~ source_code_1.cpp:1:1: note: ‘std::endl’ is defined in header ‘<ostream>’; this is probably fixable by adding ‘#include <ostream>’ +++ |+#include <ostream> 1 | source_code_1.cpp: In instantiation of ‘void foo(MemPtrList<SubRefs ...>) [with SubPtrTypes = int; SubPtrTypes X::* ...SubRefs = {&X::a}]’: source_code_1.cpp:25:6: required from here 25 | foo (MemPtrList<&X::a> {}); | ~~~~^~~~~~~~~~~~~~~~~~~~~~ source_code_1.cpp:18:13: warning: unused variable ‘dummy’ [-Wunused-variable] 18 | int dummy [] = { bar<SubPtrTypes> () ... }; | ^~~~~ source_code_1.cpp: In instantiation of ‘void foo(MemPtrList<SubRefs ...>) [with SubPtrTypes = int; SubPtrTypes X::* ...SubRefs = {&X::a}]’: source_code_1.cpp:16:6: internal compiler error: tree check: expected type_argument_pack or nontype_argument_pack, have integer_type in template_parm_natural_p, at cp/mangle.cc:1828 16 | void foo (MemPtrList<SubRefs...>) { | ^~~ 0x99e2c3 tree_check_failed(tree_node const*, char const*, int, char const*, ...) /root/gdbtest/gcc/obj/../gcc/gcc/tree.cc:8995 0x7f561c tree_check2(tree_node*, char const*, int, char const*, tree_code, tree_code) /root/gdbtest/gcc/obj/../gcc/gcc/tree.h:3643 0x7f561c template_parm_natural_p /root/gdbtest/gcc/obj/../gcc/gcc/cp/mangle.cc:1828 0x7f561c write_template_args /root/gdbtest/gcc/obj/../gcc/gcc/cp/mangle.cc:3224 0xbc5276 write_encoding /root/gdbtest/gcc/obj/../gcc/gcc/cp/mangle.cc:938 0xbc541b write_mangled_name /root/gdbtest/gcc/obj/../gcc/gcc/cp/mangle.cc:820 0xbcb4e0 mangle_decl_string /root/gdbtest/gcc/obj/../gcc/gcc/cp/mangle.cc:4420 0xbcb6ca get_mangled_id /root/gdbtest/gcc/obj/../gcc/gcc/cp/mangle.cc:4441 0xbcb6ca mangle_decl(tree_node*) /root/gdbtest/gcc/obj/../gcc/gcc/cp/mangle.cc:4479 0x16bc0fd decl_assembler_name(tree_node*) /root/gdbtest/gcc/obj/../gcc/gcc/tree.cc:719 0xeaaac1 symtab_node::get_comdat_group_id() /root/gdbtest/gcc/obj/../gcc/gcc/cgraph.h:258 0xeaaac1 analyze_functions /root/gdbtest/gcc/obj/../gcc/gcc/cgraphunit.cc:1203 0xeac22d symbol_table::finalize_compilation_unit() /root/gdbtest/gcc/obj/../gcc/gcc/cgraphunit.cc:2560 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. ******************************************************************************* Also ICE on trunk, compiler explorer:https://godbolt.org/z/7cj75MYWh *******************************************************************************