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

            Bug ID: 85146
           Summary: ICE with __direct_bases for declared but not defined
                    struct
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: reichelt at gcc dot gnu.org
                CC: paolo.carlini at oracle dot com
  Target Milestone: ---

The following valid code snippet triggers an ICE since GCC 4.7.0
(when __direct_bases was introduced):

=====================================
template<typename...> struct A {};

template<typename T> struct B
{
  typedef A<__direct_bases(T)...> C;
};

struct X;

B<X> b;
=====================================

bug.cc: In instantiation of 'struct B<X>':
bug.cc:10:6:   required from here
bug.cc:5:35: internal compiler error: Segmentation fault
   typedef A<__direct_bases(T)...> C;
                                   ^
0xd0137f crash_signal
        ../../gcc-5.1.0/gcc/toplev.c:383
0x7d6e1d tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc-5.1.0/gcc/tree.h:2845
0x7d6e1d calculate_direct_bases(tree_node*)
        ../../gcc-5.1.0/gcc/cp/semantics.c:3745
0x6a7511 tsubst_pack_expansion
        ../../gcc-5.1.0/gcc/cp/pt.c:9973
0x6a8dba tsubst_template_args
        ../../gcc-5.1.0/gcc/cp/pt.c:10221
0x6a8b93 tsubst_template_args
        ../../gcc-5.1.0/gcc/cp/pt.c:10239
0x6bf2a0 tsubst_aggr_type
        ../../gcc-5.1.0/gcc/cp/pt.c:10454
0x6ab22a tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc-5.1.0/gcc/cp/pt.c:11909
0x6c0886 tsubst_decl
        ../../gcc-5.1.0/gcc/cp/pt.c:11339
0x6ab786 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc-5.1.0/gcc/cp/pt.c:11830
0x6e0381 instantiate_class_template_1
        ../../gcc-5.1.0/gcc/cp/pt.c:9424
0x6e0381 instantiate_class_template(tree_node*)
        ../../gcc-5.1.0/gcc/cp/pt.c:9688
0x77ac6b complete_type(tree_node*)
        ../../gcc-5.1.0/gcc/cp/typeck.c:146
0x657587 start_decl_1(tree_node*, bool)
        ../../gcc-5.1.0/gcc/cp/decl.c:4900
0x678887 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
        ../../gcc-5.1.0/gcc/cp/decl.c:4863
0x76cfed cp_parser_init_declarator
        ../../gcc-5.1.0/gcc/cp/parser.c:17170
0x76f915 cp_parser_simple_declaration
        ../../gcc-5.1.0/gcc/cp/parser.c:11607
0x7693a3 cp_parser_block_declaration
        ../../gcc-5.1.0/gcc/cp/parser.c:11481
0x773249 cp_parser_declaration
        ../../gcc-5.1.0/gcc/cp/parser.c:11378
0x7718da cp_parser_declaration_seq_opt
        ../../gcc-5.1.0/gcc/cp/parser.c:11264
Please submit a full bug report, [etc.]

This is related to PR60218 where the same issue was solved
for __bases instead of __direct_bases. Paolo, you
fixed PR60218 for GCC 6. Would you mind having a look?

Reply via email to