public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58599] New: [c++11] Trouble with non-static data member initializers in templates
@ 2013-10-02 20:51 reichelt at gcc dot gnu.org
  2013-10-03 10:21 ` [Bug c++/58599] " mpolacek at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: reichelt at gcc dot gnu.org @ 2013-10-02 20:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58599
           Summary: [c++11] Trouble with non-static data member
                    initializers in templates
           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 code snippets (compiled with "-std=c++11") trigger ICEs various
places since GCC 4.7.0 (when non-static data member initializers were
introduced):

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

template<> struct A<0>
{
  template<typename, typename...> struct B
  {
    template<typename> int foo() {}

    int i = foo<int>();
  };
};
=============================================

bug.cc: In substitution of 'template<class, class ...> template<class> int
A<0>::B< <template-parameter-1-1>, <template-parameter-1-2> >::foo() [with
<template-parameter-2-1> = <missing>; <template-parameter-1-1> = int;
<template-parameter-1-2> = <missing>]':
bug.cc:9:22:   required from here
bug.cc:7:28: internal compiler error: tree check: accessed elt 2 of tree_vec
with 1 elts in tsubst_pack_expansion, at cp/pt.c:9535
     template<typename> int foo() {}
                            ^
0xce33c5 tree_vec_elt_check_failed(int, int, char const*, int, char const*)
        ../../gcc/gcc/tree.c:9361
0x5aa862 tree_vec_elt_check
        ../../gcc/gcc/tree.h:2799
0x5aa862 tsubst_pack_expansion
        ../../gcc/gcc/cp/pt.c:9535
0x5b89a2 tsubst_template_args
        ../../gcc/gcc/cp/pt.c:9738
0x5b87dc tsubst_template_args
        ../../gcc/gcc/cp/pt.c:9756
0x5b910e tsubst_aggr_type
        ../../gcc/gcc/cp/pt.c:9971
0x5acb1d tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:11364
0x5ac217 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:11354
0x5b6fa6 tsubst_arg_types
        ../../gcc/gcc/cp/pt.c:11012
0x5b73ce tsubst_function_type
        ../../gcc/gcc/cp/pt.c:11111
0x5aca1c tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:11822
0x5d21d5 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, bool, bool)
        ../../gcc/gcc/cp/pt.c:15361
0x53f0fc add_template_candidate_real
        ../../gcc/gcc/cp/call.c:2923
0x53ae69 add_template_candidate
        ../../gcc/gcc/cp/call.c:3020
0x53ae69 add_candidates
        ../../gcc/gcc/cp/call.c:5075
0x542536 build_new_method_call_1
        ../../gcc/gcc/cp/call.c:7697
0x542536 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
        ../../gcc/gcc/cp/call.c:7883
0x6427ad cp_parser_postfix_expression
        ../../gcc/gcc/cp/parser.c:5980
0x64483d cp_parser_unary_expression
        ../../gcc/gcc/cp/parser.c:7009
0x64540f cp_parser_binary_expression
        ../../gcc/gcc/cp/parser.c:7701
Please submit a full bug report, [etc.]

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

template<> struct A<0>
{
  template<typename, typename> struct B
  {
    template<typename> int foo() {}

    int i = foo<int>();
  };
};
=============================================

bug.cc: In substitution of 'template<class, class> template<class> int A<0>::B<
<template-parameter-1-1>, <template-parameter-1-2> >::foo() [with
<template-parameter-2-1> = <missing>; <template-parameter-1-1> = int;
<template-parameter-1-2> = <missing>]':
bug.cc:9:22:   required from here
bug.cc:7:28: internal compiler error: tree check: accessed elt 2 of tree_vec
with 1 elts in tsubst, at cp/pt.c:11429
     template<typename> int foo() {}
                            ^
0xce33c5 tree_vec_elt_check_failed(int, int, char const*, int, char const*)
        ../../gcc/gcc/tree.c:9361
0x5aea72 tree_vec_elt_check
        ../../gcc/gcc/tree.h:2799
0x5aea72 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:11429
0x5b86fa tsubst_template_args
        ../../gcc/gcc/cp/pt.c:9774
0x5b910e tsubst_aggr_type
        ../../gcc/gcc/cp/pt.c:9971
0x5acb1d tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:11364
0x5ac217 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:11354
0x5b6fa6 tsubst_arg_types
        ../../gcc/gcc/cp/pt.c:11012
0x5b73ce tsubst_function_type
        ../../gcc/gcc/cp/pt.c:11111
0x5aca1c tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../gcc/gcc/cp/pt.c:11822
0x5d21d5 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, bool, bool)
        ../../gcc/gcc/cp/pt.c:15361
0x53f0fc add_template_candidate_real
        ../../gcc/gcc/cp/call.c:2923
0x53ae69 add_template_candidate
        ../../gcc/gcc/cp/call.c:3020
0x53ae69 add_candidates
        ../../gcc/gcc/cp/call.c:5075
0x542536 build_new_method_call_1
        ../../gcc/gcc/cp/call.c:7697
0x542536 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
        ../../gcc/gcc/cp/call.c:7883
0x6427ad cp_parser_postfix_expression
        ../../gcc/gcc/cp/parser.c:5980
0x64483d cp_parser_unary_expression
        ../../gcc/gcc/cp/parser.c:7009
0x64540f cp_parser_binary_expression
        ../../gcc/gcc/cp/parser.c:7701
0x6458cf cp_parser_assignment_expression
        ../../gcc/gcc/cp/parser.c:7937
Please submit a full bug report, [etc.]

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

template<> struct A<0>
{
  template<typename> struct B
  {
    template<typename> int foo() {}

    int i = foo<int>();
  };
};
=============================================

bug.cc: In substitution of 'template<class> template<class> int A<0>::B<
<template-parameter-1-1> >::foo() [with <template-parameter-2-1> = <missing>;
<template-parameter-1-1> = int]':
bug.cc:9:22:   required from here
bug.cc:9:22: internal compiler error: in retrieve_specialization, at
cp/pt.c:1030
     int i = foo<int>();
                      ^
0x593b50 retrieve_specialization
        ../../gcc/gcc/cp/pt.c:1027
0x5d0ba0 instantiate_template_1
        ../../gcc/gcc/cp/pt.c:15023
0x5d0ba0 instantiate_template(tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/pt.c:15117
0x5d264a fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, bool, bool)
        ../../gcc/gcc/cp/pt.c:15466
0x53f0fc add_template_candidate_real
        ../../gcc/gcc/cp/call.c:2923
0x53ae69 add_template_candidate
        ../../gcc/gcc/cp/call.c:3020
0x53ae69 add_candidates
        ../../gcc/gcc/cp/call.c:5075
0x542536 build_new_method_call_1
        ../../gcc/gcc/cp/call.c:7697
0x542536 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
        ../../gcc/gcc/cp/call.c:7883
0x6427ad cp_parser_postfix_expression
        ../../gcc/gcc/cp/parser.c:5980
0x64483d cp_parser_unary_expression
        ../../gcc/gcc/cp/parser.c:7009
0x64540f cp_parser_binary_expression
        ../../gcc/gcc/cp/parser.c:7701
0x6458cf cp_parser_assignment_expression
        ../../gcc/gcc/cp/parser.c:7937
0x645d26 cp_parser_assignment_expression
        ../../gcc/gcc/cp/parser.c:7987
0x645d26 cp_parser_constant_expression
        ../../gcc/gcc/cp/parser.c:8197
0x6472f6 cp_parser_late_parse_one_default_arg
        ../../gcc/gcc/cp/parser.c:23056
0x6364f5 cp_parser_late_parsing_nsdmi
        ../../gcc/gcc/cp/parser.c:23110
0x6364f5 cp_parser_class_specifier_1
        ../../gcc/gcc/cp/parser.c:19068
0x638930 cp_parser_class_specifier
        ../../gcc/gcc/cp/parser.c:19101
0x638930 cp_parser_type_specifier
        ../../gcc/gcc/cp/parser.c:14080
Please submit a full bug report, [etc.]

A last variant is wrongly rejected:

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

template<> struct A<0>
{
  template<int> struct B
  {
    template<typename> int foo() {}

    int i = foo<int>();
  };
};
=============================================

bug.cc:9:22: error: no matching function for call to 'A<0>::B<<anonymous>
>::foo()'
     int i = foo<int>();
                      ^
bug.cc:9:22: note: candidate is:
bug.cc:7:28: note: template<int <anonymous> > template<class> int
A<0>::B<<anonymous> >::foo()
     template<typename> int foo() {}
                            ^
bug.cc:7:28: note:   template argument deduction/substitution failed:
bug.cc: In substitution of 'template<int <anonymous> > template<class> int
A<0>::B<<anonymous> >::foo() [with <template-parameter-2-1> = <missing>; int
<anonymous> = int]':
bug.cc:9:22:   required from here
bug.cc:7:28: error: type/value mismatch at argument 1 in template parameter
list for 'template<int <anonymous> > struct A<0>::B'
bug.cc:7:28: error:   expected a constant of type 'int', got 'int'


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-11-15 23:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-02 20:51 [Bug c++/58599] New: [c++11] Trouble with non-static data member initializers in templates reichelt at gcc dot gnu.org
2013-10-03 10:21 ` [Bug c++/58599] " mpolacek at gcc dot gnu.org
2013-10-03 23:55 ` paolo.carlini at oracle dot com
2013-10-04  7:57 ` mpolacek at gcc dot gnu.org
2013-11-15 20:32 ` reichelt at gcc dot gnu.org
2013-11-15 20:36 ` paolo.carlini at oracle dot com
2013-11-15 23:17 ` paolo at gcc dot gnu.org
2013-11-15 23:19 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).