Bug 96652 - Segmentation fault with instantiate_class_template_1
Summary: Segmentation fault with instantiate_class_template_1
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: 11.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
: 94534 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-08-17 11:20 UTC by tangyixuan
Modified: 2021-07-24 01:32 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-08-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tangyixuan 2020-08-17 11:20:22 UTC
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.
Comment 1 Patrick Palka 2020-08-18 13:31:16 UTC
Confirmed, not a regression either.
Comment 2 GCC Commits 2020-09-22 20:28:28 UTC
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.
Comment 3 Patrick Palka 2020-09-22 20:33:17 UTC
Fixed for GCC 11.
Comment 4 Andrew Pinski 2021-07-24 01:32:12 UTC
*** Bug 94534 has been marked as a duplicate of this bug. ***