http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58665

            Bug ID: 58665
           Summary: [4.9 Regression] ICE with using incomplete struct
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: reichelt at gcc dot gnu.org

The following invalid code snippet triggers an ICE on trunk:

============================
struct A;

template<int> struct B
{
  static void foo(A) {}
};

void bar()
{
  B<0>::foo(A());
}
============================

bug.cc: In static member function 'static void B<<anonymous> >::foo(A)':
bug.cc:5:19: error: '<anonymous>' has incomplete type
   static void foo(A) {}
                   ^
bug.cc:1:8: error: forward declaration of 'struct A'
 struct A;
        ^
bug.cc: In function 'void bar()':
bug.cc:10:15: error: invalid use of incomplete type 'struct A'
   B<0>::foo(A());
               ^
bug.cc:1:8: error: forward declaration of 'struct A'
 struct A;
        ^
bug.cc: In instantiation of 'static void B<<anonymous> >::foo(A) [with int
<anonymous> = 0]':
bug.cc:10:9:   required from here
bug.cc:5:15: internal compiler error: tree check: expected tree that contains
'decl minimal' structure, have 'error_mark' in regenerate_decl_from_template,
at cp/pt.c:18839
   static void foo(A) {}
               ^
0xcd9947 tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
        ../../gcc/gcc/tree.c:9348
0x5a04ff contains_struct_check
        ../../gcc/gcc/tree.h:2723
0x5a04ff regenerate_decl_from_template
        ../../gcc/gcc/cp/pt.c:18839
0x5a04ff instantiate_decl(tree_node*, int, bool)
        ../../gcc/gcc/cp/pt.c:19303
0x5dc53f instantiate_pending_templates(int)
        ../../gcc/gcc/cp/pt.c:19495
0x617966 cp_write_global_declarations()
        ../../gcc/gcc/cp/decl2.c:4065
Please submit a full bug report, [etc.]

The ICE appeared between 4.9.0-20131004 and 4.9.0-20131005.

Reply via email to