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.
Confirmed, not a regression either.
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:c4e4e163c79ca3fca265b85f44b869cb54e802b3 commit r11-3371-gc4e4e163c79ca3fca265b85f44b869cb54e802b3 Author: Patrick Palka <ppalka@redhat.com> Date: Tue Sep 22 16:26:49 2020 -0400 c++: Add test for PR96652 Fixed by r11-3361. gcc/testsuite/ChangeLog: PR c++/96652 * g++.dg/cpp0x/decltype-96652.C: New test.
Fixed for GCC 11.
*** Bug 94534 has been marked as a duplicate of this bug. ***