https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118829
Bug ID: 118829
Summary: [modules] ICE in add_indirects emitting template
typedef struct
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: ---
Consider the following:
// test.cpp
export module M;
template <typename> struct internal_capacity {
typedef struct { } type;
};
g++ -fmodules -S test.cpp:
test.cpp:1:8: internal compiler error: in add_indirects, at cp/module.cc:7660
1 | export module M;
| ^~~~~~
0x3ca1957 internal_error(char const*, ...)
../../gcc/gcc/diagnostic-global-context.cc:517
0x3c6cc2c fancy_abort(char const*, int, char const*)
../../gcc/gcc/diagnostic.cc:1722
0x1104cce add_indirects
../../gcc/gcc/cp/module.cc:7660
0x110cc3f decl_node
../../gcc/gcc/cp/module.cc:9155
0x110f8ec tree_node
../../gcc/gcc/cp/module.cc:9782
0x110c52b decl_node
../../gcc/gcc/cp/module.cc:9070
0x110f8ec tree_node
../../gcc/gcc/cp/module.cc:9782
0x10fb0e7 tree_list
../../gcc/gcc/cp/module.cc:5258
0x111ed55 write_class_def
../../gcc/gcc/cp/module.cc:12637
0x1122d24 write_definition
../../gcc/gcc/cp/module.cc:13194
0x1128679 depset::hash::find_dependencies(module_state*)
../../gcc/gcc/cp/module.cc:14445
0x11387a5 module_state::write_begin(elf_out*, cpp_reader*,
module_state_config&, unsigned int&)
../../gcc/gcc/cp/module.cc:19323
0x114071e finish_module_processing(cpp_reader*)
../../gcc/gcc/cp/module.cc:21840
0x105a7f4 c_parse_final_cleanups()
../../gcc/gcc/cp/decl2.cc:5724
0x144d9d9 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.
We hit the following assertion:
tree type = TREE_TYPE (inner);
gcc_checking_assert (DECL_ORIGINAL_TYPE (inner)
|| TYPE_NAME (type) == inner);
I think the issue is that a struct which only gets its name for linkage
purposes within a template doesn't get its TYPE_NAME adjusted at that point; it
might be enough to simply account for that in the assertion but that need more
testing.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103524
[Bug 103524] [meta-bug] modules issue