Bug 98297 - [8/9/10/11 Regression] ICE in cp_parser_elaborated_type_specifier, at cp/parser.c:19653
Summary: [8/9/10/11 Regression] ICE in cp_parser_elaborated_type_specifier, at cp/pars...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: 8.5
Assignee: Nathan Sidwell
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2020-12-15 17:24 UTC by G. Steinmetz
Modified: 2021-04-23 11:43 UTC (History)
5 users (show)

See Also:
Host:
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-12-15 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description G. Steinmetz 2020-12-15 17:24:45 UTC
Affects versions down to r8 :


$ cat z1.cc
template <template <class> class a> struct [[b]] a <int>;


$ g++-11-20201213 -c z1.cc
z1.cc:1:50: internal compiler error: Segmentation fault
    1 | template <template <class> class a> struct [[b]] a <int>;
      |                                                  ^~~~~~~
0xc8f5ff crash_signal
        ../../gcc/toplev.c:327
0x7507a5 cp_parser_elaborated_type_specifier
        ../../gcc/cp/parser.c:19653
0x739283 cp_parser_type_specifier
        ../../gcc/cp/parser.c:18393
0x73a0b6 cp_parser_decl_specifier_seq
        ../../gcc/cp/parser.c:14990
0x75bd05 cp_parser_single_declaration
        ../../gcc/cp/parser.c:30321
0x75c095 cp_parser_template_declaration_after_parameters
        ../../gcc/cp/parser.c:29984
0x75c84b cp_parser_explicit_template_declaration
        ../../gcc/cp/parser.c:30250
0x75c84b cp_parser_template_declaration_after_export
        ../../gcc/cp/parser.c:30269
0x75ecf9 cp_parser_declaration
        ../../gcc/cp/parser.c:13996
0x75e183 cp_parser_translation_unit
        ../../gcc/cp/parser.c:4926
0x75e183 c_parse_file()
        ../../gcc/cp/parser.c:45106
0x82acf2 c_common_parse_file()
        ../../gcc/c-family/c-opts.c:1211
Comment 1 Marek Polacek 2020-12-15 18:31:10 UTC
Confirmed.
Comment 2 Martin Liška 2020-12-16 08:23:50 UTC
Likely started with r8-2567-g776ff3efa9de7fce.
Comment 3 Nathan Sidwell 2020-12-16 19:59:48 UTC
Fixed trunk, 8d8bb85b486 2020-12-16 | c++: Fix template parm ICE [PR 98297]

backports to 10, 9, & 8 in progress
Comment 4 Nathan Sidwell 2020-12-16 21:41:58 UTC
8, 9 & 10 fixed
Comment 5 Jakub Jelinek 2021-04-23 09:31:47 UTC
Note, the testcase FAILs on the 8 branch, the emitted error is different.
$ gcc-9/obj28/gcc/cc1plus -quiet -std=c++11 /tmp/pr98297.C -o /tmp/pr98297.s
/tmp/pr98297.C:5:1: warning: ‘b’ attribute directive ignored [-Wattributes]
    5 | a <int>; // { dg-error "does not declare anything" }
      | ^~~~~~~
/tmp/pr98297.C:5:1: error: declaration does not declare anything [-fpermissive]
$ gcc-8/obj32/gcc/cc1plus -quiet -std=c++11 /tmp/pr98297.C -o /tmp/pr98297.s
/tmp/pr98297.C:5:1: warning: ‘b’ attribute directive ignored [-Wattributes]
 a <int>; // { dg-error "does not declare anything" }
 ^~~~~~~
/tmp/pr98297.C:5:1: error: name of class shadows template template parameter ‘a’
$ gcc-8/obj30/gcc/cc1plus -quiet -std=c++11 /tmp/pr98297.C -o /tmp/pr98297.s
/tmp/pr98297.C:5:1: internal compiler error: Segmentation fault
 a <int>; // { dg-error "does not declare anything" }
 ^~~~~~~
gcc-8/obj30 is 5 months old snapshot which expectedly ICEs, but the middle error is different from what the test expects.
Comment 6 Jakub Jelinek 2021-04-23 11:43:20 UTC
Ah, tracked already in PR98358.