https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114954
Bug ID: 114954 Summary: [modules] ICE in write_class_def with templated union type 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 Blocks: 103524 Target Milestone: --- The following sample crashes on trunk: export module main; template <int N> union U { private: char a[N + 1]; int b; }; U<4> p; With 'g++ -fmodules-ts -S main.cpp': ~/ice/main.cpp:1:8: internal compiler error: in write_class_def, at cp/module.cc:12118 1 | export module main; | ^~~~~~ 0x1010c67 write_class_def ../../gcc/gcc/cp/module.cc:12118 0x1014d91 write_definition ../../gcc/gcc/cp/module.cc:12731 0x101880e depset::hash::find_dependencies(module_state*) ../../gcc/gcc/cp/module.cc:13640 0x1026a62 module_state::write_begin(elf_out*, cpp_reader*, module_state_config&, unsigned int&) ../../gcc/gcc/cp/module.cc:18253 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 assertion that fails is /* Every class but __as_base has a type-specific. */ gcc_checking_assert (!TYPE_LANG_SPECIFIC (type) == IS_FAKE_BASE_TYPE (type)); The issue looks to be that a union `__as_base` type doesn't satisfy the 'IS_FAKE_BASE_TYPE', which only applies to RECORD_TYPEs. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103524 [Bug 103524] [meta-bug] modules issue