https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95902

            Bug ID: 95902
           Summary: ICE: tree check: expected tree_list, have ggc_freed in
                    get_attribute_name, at attribs.c:841
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: p.vanhoof at oma dot be
  Target Milestone: ---

Created attachment 48786
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48786&action=edit
Code that triggers the ICE

% g++ --version
g++ (GCC) 11.0.0 20200604 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

With this compiler, the attached code generates an ICE:

% g++ -g -c bug.cc
bug.cc:53:3: internal compiler error: tree check: expected tree_list, have
ggc_freed in get_attribute_name, at attribs.c:841
   53 | } ql;
      |   ^~
0x7ecec1 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc-git/gcc/tree.c:9685
0x6c8201 tree_check(tree_node const*, char const*, int, char const*, tree_code)
        ../../gcc-git/gcc/tree.h:3552
0x6c8201 get_attribute_name(tree_node const*)
        ../../gcc-git/gcc/attribs.c:841
0xab8c79 private_lookup_attribute(char const*, unsigned long, tree_node*)
        ../../gcc-git/gcc/attribs.c:1812
0x932338 grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*,
decl_context, int, tree_node**)
        ../../gcc-git/gcc/attribs.h:179
0x93e188 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
        ../../gcc-git/gcc/cp/decl.c:5231
0x9eae3d cp_parser_init_declarator
        ../../gcc-git/gcc/cp/parser.c:20817
0x9cc6c2 cp_parser_simple_declaration
        ../../gcc-git/gcc/cp/parser.c:13785
0x9f5916 cp_parser_declaration
        ../../gcc-git/gcc/cp/parser.c:13484
0x9f605a cp_parser_translation_unit
        ../../gcc-git/gcc/cp/parser.c:4761
0x9f605a c_parse_file()
        ../../gcc-git/gcc/cp/parser.c:44034
0xb0b81b c_common_parse_file()
        ../../gcc-git/gcc/c-family/c-opts.c:1190

With older g++ versions like 10.1.0, 9.3.0, and 8.4.0 it compiles correctly, so
this seems to be a regression.

Adding -save-temps to the command line makes the ICE go away, so unfortunately
the preprocessed source is not useful... I hope you can reproduce it without
this. The -g flag is essential to trigger the ICE.

Reply via email to