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

            Bug ID: 84792
           Summary: [6/7/8 Regression] ICE with broken typedef of a struct
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Keywords: error-recovery, ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: reichelt at gcc dot gnu.org
  Target Milestone: ---

The following invalid code snippet triggers an ICE since GCC 4.9.0:

==========================
struct A {};

typedef struct
{
  virtual void foo() {}
} A::B;
==========================

bug.cc:6:6: error: typedef name may not be a nested-name-specifier
 } A::B;
      ^
bug.cc:6:6: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in write_name, at cp/mangle.c:903
0x78b66e tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        ../../gcc/gcc/tree.c:9385
0x618520 tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        ../../gcc/gcc/tree.h:3255
0x618520 write_name
        ../../gcc/gcc/cp/mangle.c:903
0x8e3548 write_class_enum_type
        ../../gcc/gcc/cp/mangle.c:2809
0x8e3548 write_type
        ../../gcc/gcc/cp/mangle.c:2222
0x8e6e41 write_type
        ../../gcc/gcc/cp/mangle.c:3955
0x8e6e41 mangle_special_for_type
        ../../gcc/gcc/cp/mangle.c:3955
0x8b3cba reset_type_linkage_2
        ../../gcc/gcc/cp/decl2.c:2759
0x887382 name_unnamed_type(tree_node*, tree_node*)
        ../../gcc/gcc/cp/decl.c:9983
0x8a74bd grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*,
decl_context, int, tree_node**)
        ../../gcc/gcc/cp/decl.c:11737
0x8a9336 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
        ../../gcc/gcc/cp/decl.c:4998
0x9391e9 cp_parser_init_declarator
        ../../gcc/gcc/cp/parser.c:19598
0x940928 cp_parser_simple_declaration
        ../../gcc/gcc/cp/parser.c:13057
0x941738 cp_parser_block_declaration
        ../../gcc/gcc/cp/parser.c:12882
0x945692 cp_parser_declaration
        ../../gcc/gcc/cp/parser.c:12780
0x945aa1 cp_parser_declaration_seq_opt
        ../../gcc/gcc/cp/parser.c:12656
0x945d94 cp_parser_translation_unit
        ../../gcc/gcc/cp/parser.c:4561
0x945d94 c_parse_file()
        ../../gcc/gcc/cp/parser.c:38995
0xa44906 c_common_parse_file()
        ../../gcc/gcc/c-family/c-opts.c:1132
Please submit a full bug report, [etc.]


Without the 'virtual' keyword I get a different stack-trace:

==========================
struct A {};

typedef struct
{
  void foo() {}
} A::B;
==========================

bug.cc:6:6: error: typedef name may not be a nested-name-specifier
 } A::B;
      ^
bug.cc:5:8: internal compiler error: tree check: expected tree that contains
'decl common' structure, have 'error_mark' in get_abi_tags, at cp/mangle.c:521
   void foo() {}
        ^~~
0x78bb9b tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
        ../../gcc/gcc/tree.c:9507
0x617ad0 contains_struct_check(tree_node*, tree_node_structure_enum, char
const*, int, char const*)
        ../../gcc/gcc/tree.h:3246
0x617ad0 get_abi_tags
        ../../gcc/gcc/cp/mangle.c:521
0x8e54df write_unqualified_name
        ../../gcc/gcc/cp/mangle.c:1459
0x8e9a67 write_prefix
        ../../gcc/gcc/cp/mangle.c:1166
0x8e9de6 write_nested_name
        ../../gcc/gcc/cp/mangle.c:1083
0x8e2b97 write_name
        ../../gcc/gcc/cp/mangle.c:976
0x8e2426 write_encoding
        ../../gcc/gcc/cp/mangle.c:825
0x8e6cb4 mangle_decl_string
        ../../gcc/gcc/cp/mangle.c:3792
0x8ecae0 get_mangled_id
        ../../gcc/gcc/cp/mangle.c:3814
0x8ecae0 mangle_decl(tree_node*)
        ../../gcc/gcc/cp/mangle.c:3852
0x11408cd decl_assembler_name(tree_node*)
        ../../gcc/gcc/tree.c:687
0xaee217 symtab_node::get_comdat_group_id()
        ../../gcc/gcc/cgraph.h:215
0xaee217 analyze_functions
        ../../gcc/gcc/cgraphunit.c:1081
0xaef582 symbol_table::finalize_compilation_unit()
        ../../gcc/gcc/cgraphunit.c:2691
Please submit a full bug report, [etc.]

Reply via email to