https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118807
Bug ID: 118807 Summary: [modules] ICE in c_tree_chain_next during GGC with explicit instantiations Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nshead at gcc dot gnu.org Target Milestone: --- The following sample ICEs during garbage collection on trunk: $ cat test.cpp module; template <typename> class basic_streambuf; template <typename> struct basic_streambuf { friend void __istream_extract(); }; template class basic_streambuf<char>; template class basic_streambuf<wchar_t>; $ g++ -fmodules --param=ggc-min-expand=0 --param=ggc-min-heapsize=0 -Wno-global-module -S test.cpp test.cpp:7:40: internal compiler error: Segmentation fault 7 | template class basic_streambuf<wchar_t>; | ^ 0x3ca55b1 internal_error(char const*, ...) ../../gcc/gcc/diagnostic-global-context.cc:517 0x1d14f82 crash_signal ../../gcc/gcc/toplev.cc:322 0x7f494591131f ??? ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 0x135ba02 c_tree_chain_next(tree_node*) ../../gcc/gcc/c-family/c-common.h:1442 0x134e772 gt_ggc_mx_lang_tree_node(void*) ./gt-cp-tree.h:108 0x1350abb gt_ggc_mx_lang_tree_node(void*) ./gt-cp-tree.h:453 0x1351741 gt_ggc_mx_lang_tree_node(void*) ./gt-cp-tree.h:610 0x1351bdc gt_ggc_mx_lang_tree_node(void*) ./gt-cp-tree.h:669 0x134e576 gt_ggc_mx_lang_decl(void*) ./gt-cp-tree.h:60 0x135002f gt_ggc_mx_lang_tree_node(void*) ./gt-cp-tree.h:345 0x117cf9d gt_ggc_mx_cp_binding_level(void*) ./gt-cp-name-lookup.h:28 0x117d04b gt_ggc_mx_cp_binding_level(void*) ./gt-cp-name-lookup.h:34 0x134e690 gt_ggc_mx_lang_decl(void*) ./gt-cp-tree.h:87 0x134f011 gt_ggc_mx_lang_tree_node(void*) ./gt-cp-tree.h:214 0x17b02e6 ggc_mark_root_tab ../../gcc/gcc/ggc-common.cc:75 0x17b0401 ggc_mark_roots() ../../gcc/gcc/ggc-common.cc:104 0x14a5373 ggc_collect(ggc_collect) ../../gcc/gcc/ggc-page.cc:2231 0x105968a c_parse_final_cleanups() ../../gcc/gcc/cp/decl2.cc:5504 0x144d679 c_common_parse_file() ../../gcc/gcc/c-family/c-opts.cc:1408 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. This appears to have worked in GCC 14: https://godbolt.org/z/sbvPYejhE