https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96652
Bug ID: 96652 Summary: Segmentation fault with instantiate_class_template_1 Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tangyixuan at mail dot dlut.edu.cn Target Milestone: --- g++ crashes on the following code, while clang++ compiles successfully: $: cat s.cpp struct A {}; template <typename T> struct B { A a; friend decltype(a); }; int main() { A a; B<int> b; } $: g++ -std=c++11 -c s.cpp s.cpp: In instantiation of ‘struct B<int>’: s.cpp:12:12: required from here s.cpp:5:7: internal compiler error: Segmentation fault 5 | A a; | ^ 0xc6a68f crash_signal ../../gcc-11-20200628/gcc/toplev.c:328 0x77745a instantiate_class_template_1 ../../gcc-11-20200628/gcc/cp/pt.c:11974 0x778202 instantiate_class_template(tree_node*) ../../gcc-11-20200628/gcc/cp/pt.c:12098 0x7a7d8d complete_type(tree_node*) ../../gcc-11-20200628/gcc/cp/typeck.c:137 0x7a7d8d complete_type(tree_node*) ../../gcc-11-20200628/gcc/cp/typeck.c:111 0x6a031b start_decl_1(tree_node*, bool) ../../gcc-11-20200628/gcc/cp/decl.c:5490 0x6b0bef start_decl(cp_declarator const*, cp_decl_specifier_seq*, int, tree_node*, tree_node*, tree_node**) ../../gcc-11-20200628/gcc/cp/decl.c:5453 0x738d3e cp_parser_init_declarator ../../gcc-11-20200628/gcc/cp/parser.c:20818 0x71c052 cp_parser_simple_declaration ../../gcc-11-20200628/gcc/cp/parser.c:13785 0x71dbdd cp_parser_declaration_statement ../../gcc-11-20200628/gcc/cp/parser.c:13217 0x71e7b0 cp_parser_statement ../../gcc-11-20200628/gcc/cp/parser.c:11523 0x71f5c8 cp_parser_statement_seq_opt ../../gcc-11-20200628/gcc/cp/parser.c:11889 0x71f680 cp_parser_compound_statement ../../gcc-11-20200628/gcc/cp/parser.c:11839 0x735280 cp_parser_function_body ../../gcc-11-20200628/gcc/cp/parser.c:23116 0x735280 cp_parser_ctor_initializer_opt_and_function_body ../../gcc-11-20200628/gcc/cp/parser.c:23167 0x73887d cp_parser_function_definition_after_declarator ../../gcc-11-20200628/gcc/cp/parser.c:29063 0x73975f cp_parser_function_definition_from_specifiers_and_declarator ../../gcc-11-20200628/gcc/cp/parser.c:28979 0x73975f cp_parser_init_declarator ../../gcc-11-20200628/gcc/cp/parser.c:20722 0x71c052 cp_parser_simple_declaration ../../gcc-11-20200628/gcc/cp/parser.c:13785 0x741e16 cp_parser_declaration ../../gcc-11-20200628/gcc/cp/parser.c:13484 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.