Bug 66647 - [5/6 regression] ICE: in instantiate_class_template_1, at cp/pt.c:9254
Summary: [5/6 regression] ICE: in instantiate_class_template_1, at cp/pt.c:9254
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: 5.2
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2015-06-24 06:47 UTC by Allan McRae
Modified: 2015-06-25 10:24 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.9.2
Known to fail: 5.0, 6.0
Last reconfirmed: 2015-06-24 00:00:00


Attachments
testcase (592 bytes, text/plain)
2015-06-24 06:47 UTC, Allan McRae
Details
Unreduced testcase (368 bytes, text/x-csrc)
2015-06-24 08:25 UTC, Allan McRae
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Allan McRae 2015-06-24 06:47:17 UTC
Created attachment 35838 [details]
testcase

An ICE seen in gcc-5-20150519.  Works in 4.9.2.

A reducded-ish testcase attached.

g++ -std=c++11 testcase.ii
Comment 1 Markus Trippelsdorf 2015-06-24 07:10:58 UTC
Could you please attach the unreduced testcase?
Comment 2 Markus Trippelsdorf 2015-06-24 08:06:28 UTC
markus@x4 tmp % cat testcase.ii
template <typename _Tp> struct A
{
  static constexpr _Tp value = 1;
};
template <typename> class B
{
public:
  template <typename> struct rebind
  {
  };
};

template <typename _Alloc, typename _Tp> class C
{
  template <typename _Alloc2, typename _Tp2>
  static A<int> _S_chk (typename _Alloc2::template rebind<_Tp2> *);

public:
  using __type = decltype (_S_chk<_Alloc, _Tp> (0));
};

template <typename _Alloc, typename _Tp, int = C<_Alloc, _Tp>::__type::value>
struct D;
template <typename _Alloc, typename _Tp> struct D<_Alloc, _Tp, 1>
{
  typedef typename _Alloc::template rebind<_Tp> __type;
};
template <typename _Alloc> struct F
{
  template <typename _Tp> using rebind_alloc = typename D<_Alloc, _Tp>::__type;
};
template <typename _Alloc> struct __alloc_traits
{
  template <typename> struct rebind
  {
    typedef typename F<_Alloc>::template rebind_alloc<int> other;
  };
};
template <typename _Alloc> struct G
{
  typename __alloc_traits<_Alloc>::template rebind<int>::other _Tp_alloc_type;
};
template <typename _Tp, typename _Alloc = B<_Tp> > class vector : G<_Alloc>
{
};

template <int> using tfuncptr = void();
template <int d> struct H
{
  vector<tfuncptr<d> > funcs;
};


markus@x4 tmp % g++ -std=c++11 testcase.ii
testcase.ii: In instantiation of ‘struct B<void()>::rebind<int>’:
testcase.ii:41:64:   required from ‘struct G<B<tfuncptr<d> > >’
testcase.ii:43:58:   required from ‘class vector<tfuncptr<d> >’
testcase.ii:50:24:   required from here
testcase.ii:8:30: internal compiler error: in instantiate_class_template_1, at cp/pt.c:9267
   template <typename> struct rebind
                              ^
0x662f01 instantiate_class_template_1
        ../../gcc/gcc/cp/pt.c:9266
0x662f01 instantiate_class_template(tree_node*)
        ../../gcc/gcc/cp/pt.c:9730
0x70763b complete_type(tree_node*)
        ../../gcc/gcc/cp/typeck.c:139
0x6629b9 instantiate_class_template_1
        ../../gcc/gcc/cp/pt.c:9503
0x6629b9 instantiate_class_template(tree_node*)
        ../../gcc/gcc/cp/pt.c:9730
0x70763b complete_type(tree_node*)
        ../../gcc/gcc/cp/typeck.c:139
0x70782f complete_type_or_maybe_complain(tree_node*, tree_node*, int)
        ../../gcc/gcc/cp/typeck.c:151
0x5faf79 xref_basetypes(tree_node*, tree_node*)
        ../../gcc/gcc/cp/decl.c:12474
0x662246 instantiate_class_template_1
        ../../gcc/gcc/cp/pt.c:9328
0x662246 instantiate_class_template(tree_node*)
        ../../gcc/gcc/cp/pt.c:9730
0x70763b complete_type(tree_node*)
        ../../gcc/gcc/cp/typeck.c:139
0x609350 grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*, decl_context, int, tree_node**)
        ../../gcc/gcc/cp/decl.c:10782
0x6ac556 grokfield(cp_declarator const*, cp_decl_specifier_seq*, tree_node*, bool, tree_node*, tree_node*)
        ../../gcc/gcc/cp/decl2.c:876
0x6fb20b cp_parser_member_declaration
        ../../gcc/gcc/cp/parser.c:21123
0x6d6e0d cp_parser_member_specification_opt
        ../../gcc/gcc/cp/parser.c:20675
0x6d6e0d cp_parser_class_specifier_1
        ../../gcc/gcc/cp/parser.c:19867
0x6d6e0d cp_parser_class_specifier
        ../../gcc/gcc/cp/parser.c:20103
0x6d6e0d cp_parser_type_specifier
        ../../gcc/gcc/cp/parser.c:14732
0x6ea87e cp_parser_decl_specifier_seq
        ../../gcc/gcc/cp/parser.c:11958
0x6f9e98 cp_parser_single_declaration
        ../../gcc/gcc/cp/parser.c:23771
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 3 Marek Polacek 2015-06-24 08:23:58 UTC
Started with r217250.
Comment 4 Allan McRae 2015-06-24 08:25:32 UTC
Created attachment 35839 [details]
Unreduced testcase

Unreduced testcase attached.
Comment 5 Jason Merrill 2015-06-24 20:00:00 UTC
Author: jason
Date: Wed Jun 24 19:59:28 2015
New Revision: 224917

URL: https://gcc.gnu.org/viewcvs?rev=224917&root=gcc&view=rev
Log:
	PR c++/66647
	* pt.c (dependent_type_p_r): Check for dependent alias template
	specialization sooner.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/alias-decl-49.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
Comment 6 Jason Merrill 2015-06-24 20:24:24 UTC
Author: jason
Date: Wed Jun 24 20:23:53 2015
New Revision: 224921

URL: https://gcc.gnu.org/viewcvs?rev=224921&root=gcc&view=rev
Log:
	PR c++/66647
	* pt.c (dependent_type_p_r): Check for dependent alias template
	specialization sooner.

Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/cpp0x/alias-decl-49.C
Modified:
    branches/gcc-5-branch/gcc/cp/ChangeLog
    branches/gcc-5-branch/gcc/cp/pt.c
Comment 7 Jason Merrill 2015-06-24 20:27:18 UTC
Fixed.
Comment 8 Benny 2015-06-25 10:24:31 UTC
Wow, that went really quick! Many thanks! Very impressive.