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

            Bug ID: 58649
           Summary: [4.7/4.8/4.9 Regression] ICE with use of enum before
                    declaration
           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 since GCC 4.2.0:

====================================
template<typename> void foo()
{
  E();
  enum E {};
}

template void foo<int>();
====================================

bug.cc: In function 'void foo()':
bug.cc:3:5: error: there are no arguments to 'E' that depend on a template
parameter, so a declaration of 'E' must be available [-fpermissive]
   E();
     ^
bug.cc:3:5: note: (if you use '-fpermissive', G++ will accept your code, but
allowing the use of an undeclared name is deprecated)
bug.cc: In instantiation of 'void foo() [with <template-parameter-1-1> = int]':
bug.cc:7:24:   required from here
bug.cc:3:5: error: 'E' was not declared in this scope
bug.cc:4:8: internal compiler error: tree check: expected enumeral_type, have
error_mark in lookup_template_class_1, at cp/pt.c:7479
   enum E {};
        ^
0xcd860a tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc/gcc/tree.c:9176
0x5b3e5d tree_check
        ../../gcc/gcc/tree.h:2609
0x5b3e5d lookup_template_class_1
        ../../gcc/gcc/cp/pt.c:7479
0x5b3e5d lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
        ../../gcc/gcc/cp/pt.c:7695
0x5b894e tsubst_aggr_type
        ../../gcc/gcc/cp/pt.c:9977
0x5ac34b tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:11367
0x5bd413 tsubst_decl
        ../../gcc/gcc/cp/pt.c:10752
0x5ac895 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:11288
0x5a208c tsubst_expr
        ../../gcc/gcc/cp/pt.c:13148
0x5a1643 tsubst_expr
        ../../gcc/gcc/cp/pt.c:13091
0x5a2421 tsubst_expr
        ../../gcc/gcc/cp/pt.c:13287
0x59fdbf instantiate_decl(tree_node*, int, bool)
        ../../gcc/gcc/cp/pt.c:19394
0x5dc61f instantiate_pending_templates(int)
        ../../gcc/gcc/cp/pt.c:19495
0x617896 cp_write_global_declarations()
        ../../gcc/gcc/cp/decl2.c:4065
Please submit a full bug report, [etc.]

Reply via email to