https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114950
Bug ID: 114950 Summary: [modules] ICE in binding_cmp when merging friend functions in partitions Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nshead at gcc dot gnu.org Blocks: 103524 Target Milestone: --- The following code ICEs on trunk: // format.h template <typename T> struct A { friend void x(); }; template <typename T> struct B { virtual void f() { A<T> r; } }; template struct B<int>; // a.cpp module M:a; extern "C++" { #include "format.h" } // b.cpp module M:b; extern "C++" { #include "format.h" } // m.cpp export module M; import :a; import :b; Compiled with 'g++ -fmodules-ts -S [abm].cpp' results in: ~/ice/m.cpp:1:8: internal compiler error: in binding_cmp, at cp/module.cc:13712 1 | export module M; | ^~~~~~ 0x1018b62 binding_cmp ../../gcc/gcc/cp/module.cc:13712 0x3893656 cmp1<sort_ctx> ../../gcc/gcc/sort.cc:151 0x3892f8e netsort<sort_ctx> ../../gcc/gcc/sort.cc:168 0x38927cd mergesort<sort_ctx> ../../gcc/gcc/sort.cc:205 0x389249a gcc_qsort(void*, unsigned long, unsigned long, int (*)(void const*, void const*)) ../../gcc/gcc/sort.cc:268 0x1019128 depset::hash::finalize_dependencies() ../../gcc/gcc/cp/module.cc:13788 0x1026a71 module_state::write_begin(elf_out*, cpp_reader*, module_state_config&, unsigned int&) ../../gcc/gcc/cp/module.cc:18255 0x102e39f finish_module_processing(cpp_reader*) ../../gcc/gcc/cp/module.cc:20693 0xf50556 c_parse_final_cleanups() ../../gcc/gcc/cp/decl2.cc:5393 0x131e75f c_common_parse_file() ../../gcc/gcc/c-family/c-opts.cc:1329 The issue looks to be that the friend function is added to multiple depsets. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103524 [Bug 103524] [meta-bug] modules issue