This is the mail archive of the gcc-patches@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]

[C++ PATCH] Fix ICE in unify with variadic templates (PR c++/32565)


Hi!

As shown on these I believe valid testcases, when unifying
BOUND_TEMPLATE_TEMPLATE_PARMs, we really can't assume if one {parm,arg}vec
argument is a parameter pack, the other will be as well.  Fixed by using
expand_template_argument_pack on both vectors so that we unify corresponding
parameters.

Tested on x86_64-linux, ok for trunk?

2007-11-15  Jakub Jelinek  <jakub@redhat.com>

	PR c++/32565
	* pt.c (unify) <case BOUND_TEMPLATE_TEMPLATE_PARM>: Expand both
	parmvec and argvec with expand_template_argument_pack.

	* g++.dg/cpp0x/variadic84.C: New test.
	* g++.dg/cpp0x/variadic85.C: New test.

--- gcc/cp/pt.c.jj	2007-11-13 17:09:58.000000000 +0100
+++ gcc/cp/pt.c	2007-11-15 13:02:05.000000000 +0100
@@ -12722,6 +12722,9 @@ unify (tree tparms, tree targs, tree par
 	       rather than the whole TREE_VEC since they can have
 	       different number of elements.  */
 
+	    parmvec = expand_template_argument_pack (parmvec);
+	    argvec = expand_template_argument_pack (argvec);
+
 	    for (i = 0; i < TREE_VEC_LENGTH (parmvec); ++i)
 	      {
 		if (unify (tparms, targs,
--- gcc/testsuite/g++.dg/cpp0x/variadic84.C.jj	2007-11-14 20:46:13.000000000 +0100
+++ gcc/testsuite/g++.dg/cpp0x/variadic84.C	2007-11-14 20:46:08.000000000 +0100
@@ -0,0 +1,26 @@
+// PR c++/32565
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+template<typename...> struct A1;
+template<template<int...> class T> struct A1<T<0> > {};
+template<typename...> struct A2;
+template<template<int...> class T> struct A2<T<0, 1> > {};
+template<typename...> struct A3;
+template<template<int, int...> class T> struct A3<T<0, 1> > {};
+template<typename...> struct A4;
+template<template<typename...> class T> struct A4<T<int> > {};
+template<typename...> struct A5;
+template<template<typename...> class T> struct A5<T<int, long> > {};
+template<typename...> struct A6;
+template<template<typename, typename...> class T> struct A6<T<int, long> > {};
+template<int> struct B1 {};
+template<int, int> struct B2 {};
+template<typename> struct B3 {};
+template<typename, typename> struct B4 {};
+A1<B1<0> > a1;
+A2<B2<0, 1> > a2;
+A3<B2<0, 1> > a3;
+A4<B3<int> > a4;
+A5<B4<int, long> > a5;
+A6<B4<int, long> > a6;
--- gcc/testsuite/g++.dg/cpp0x/variadic85.C.jj	2007-11-15 13:11:47.000000000 +0100
+++ gcc/testsuite/g++.dg/cpp0x/variadic85.C	2007-11-15 12:00:39.000000000 +0100
@@ -0,0 +1,10 @@
+// PR c++/32565
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+template<typename...> struct A1;
+template<template<int, int...> class T> struct A1<T<0, 1> > {};
+template<int, int, int...> struct B1 {};
+A1<B1<0, 1> > a1;
+template<int...> struct B2 {};
+A1<B2<0, 1> > a2;

	Jakub


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