This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/58674] New: [4.8/4.9 Regression] [c++11] ICE with template using declaration


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

            Bug ID: 58674
           Summary: [4.8/4.9 Regression] [c++11] ICE with template using
                    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 (compiled with "-std=c++11") triggers an ICE
since GCC 4.8.0:

====================================
template<int> struct A {};

template<int N> using B = A<N>;

template<typename T> struct C
{
  B<T::i> b;
};

struct X
{
  static const int i;
};

C<X> c;
====================================

bug.cc: In substitution of 'template<int N> using B = A<N> [with int N =
X::i]':
bug.cc:7:11:   required from 'struct C<X>'
bug.cc:15:6:   required from here
bug.cc:7:11: error: the value of 'X::i' is not usable in a constant expression
   B<T::i> b;
           ^
bug.cc:12:20: note: 'X::i' was not initialized with a constant expression
   static const int i;
                    ^
bug.cc:7:11: note: in template argument for type 'int' 
   B<T::i> b;
           ^
bug.cc:7:11: internal compiler error: tree check: expected tree_vec, have
error_mark in get_innermost_template_args, at cp/pt.c:569
0xcec8da tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc/gcc/tree.c:9176
0x587845 tree_check
        ../../gcc/gcc/tree.h:2609
0x587845 get_innermost_template_args(tree_node*, int)
        ../../gcc/gcc/cp/pt.c:569
0x5d0585 instantiate_template_1
        ../../gcc/gcc/cp/pt.c:15042
0x5d0585 instantiate_template(tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/pt.c:15117
0x5ac7bb instantiate_alias_template
        ../../gcc/gcc/cp/pt.c:15147
0x5ac7bb tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:11312
0x5bca41 tsubst_decl
        ../../gcc/gcc/cp/pt.c:10657
0x5ac634 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:11285
0x5d8fc1 instantiate_class_template_1
        ../../gcc/gcc/cp/pt.c:8952
0x5d8fc1 instantiate_class_template(tree_node*)
        ../../gcc/gcc/cp/pt.c:9216
0x66435b complete_type(tree_node*)
        ../../gcc/gcc/cp/typeck.c:132
0x554fa9 start_decl_1(tree_node*, bool)
        ../../gcc/gcc/cp/decl.c:4670
0x57edbd start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
        ../../gcc/gcc/cp/decl.c:4633
0x650fd8 cp_parser_init_declarator
        ../../gcc/gcc/cp/parser.c:16453
0x65187f cp_parser_simple_declaration
        ../../gcc/gcc/cp/parser.c:10995
0x653700 cp_parser_block_declaration
        ../../gcc/gcc/cp/parser.c:10876
0x65c73e cp_parser_declaration
        ../../gcc/gcc/cp/parser.c:10773
0x65b4aa cp_parser_declaration_seq_opt
        ../../gcc/gcc/cp/parser.c:10659
0x65cd76 cp_parser_translation_unit
        ../../gcc/gcc/cp/parser.c:3939
Please submit a full bug report, [etc.]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]