Bug 54653 - [4.6/4.7/4.8 Regression] tsubst_template_parms ICE
Summary: [4.6/4.7/4.8 Regression] tsubst_template_parms ICE
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.1
: P3 normal
Target Milestone: 4.8.0
Assignee: Jason Merrill
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2012-09-21 10:14 UTC by Jakub Jelinek
Modified: 2012-12-06 14:41 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-10-01 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2012-09-21 10:14:25 UTC
union A {};

struct B
{
  template <class T> struct C {};
};

template <class F, template <class T> class D = B::template C>
struct E;

template <typename R, template <class T> class D>
struct E <R (), D>
{
  void (*f) (A &);
  template <class I, template <class T> class J>
  struct G { static void d (A &); };
  template <class H> inline E (H &fn)
  {
    f = &(G <H, D>::d);
  }
};

template <typename R, template <class T> class D>
struct E <R (), D>::G <R (*) (), D>
{
};

struct Z { int z; };

int
main ()
{
  Z t = {};
  E <int ()> f (t);
}

ICEs in tsubst_template_parms, because parms is NULL.  The ICE started in between r128000 and r128500.
Comment 1 Paolo Carlini 2012-10-01 16:26:22 UTC
H.J. can you help finding the offending commit?
Comment 2 H.J. Lu 2012-10-01 18:37:26 UTC
It is caused by revision 128076:

http://gcc.gnu.org/ml/gcc-cvs/2007-09/msg00070.html
Comment 3 Paolo Carlini 2012-10-01 22:09:53 UTC
Thanks H.J. let's add Jason in CC.
Comment 4 Jason Merrill 2012-12-05 17:46:21 UTC
This code is actually ill-formed; the specialization

template <typename R, template <class T> class D>
struct E <R (), D>::G <R (*) (), D>
{
};

only has one template-header, and should have two.  Furthermore, this is a full specialization of a member of a partial specialization, which is not allowed.

14.8/16: "the declaration shall not explicitly specialize a class member template if its enclosing class templates are not explicitly specialized as well."
Comment 5 Jakub Jelinek 2012-12-05 17:49:20 UTC
Perhaps errors introduced during my testcase reduction.  The original bugreport is
https://bugzilla.redhat.com/show_bug.cgi?id=858351
Comment 6 Jason Merrill 2012-12-06 14:37:08 UTC
Author: jason
Date: Thu Dec  6 14:37:04 2012
New Revision: 194249

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194249
Log:
	PR c++/54653
	* parser.c (cp_parser_class_head): A partial specialization scope
	counts as a template.
	* pt.c (tsubst_template_parms): Handle template template parm parms.
	(tsubst_decl) [TEMPLATE_DECL]: Handle getting a template template
	argument back.

Added:
    trunk/gcc/testsuite/g++.dg/template/partial-specialization2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
Comment 7 Jason Merrill 2012-12-06 14:41:42 UTC
Fixed for 4.8, not backporting fixes for invalid code bugs.