diff mbox

C++ PATCH for c++/61134 (variadic templates)

Message ID 538D556D.8020301@redhat.com
State New
Headers show

Commit Message

Jason Merrill June 3, 2014, 4:56 a.m. UTC
Here the problem was that Fixed<Fields> was canonicalized to refer to 
the Fields from the New template, so the parameter pack in typename 
Fixed<Fields>::name... is the Fields from New rather than the one from 
CreateMetric, and so using == to compare them breaks.  If we use 
template_args_equal instead, everything is fine.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit adca28aaa03741586551ef6355c799e0fab967af
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Jun 2 21:35:52 2014 -0400

    	PR c++/61134
    	* pt.c (pack_deducible_p): Handle canonicalization.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index c0e0646..a55a06b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -15765,7 +15765,7 @@  pack_deducible_p (tree parm, tree fn)
 	continue;
       for (packs = PACK_EXPANSION_PARAMETER_PACKS (type);
 	   packs; packs = TREE_CHAIN (packs))
-	if (TREE_VALUE (packs) == parm)
+	if (template_args_equal (TREE_VALUE (packs), parm))
 	  {
 	    /* The template parameter pack is used in a function parameter
 	       pack.  If this is the end of the parameter list, the
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic158.C b/gcc/testsuite/g++.dg/cpp0x/variadic158.C
new file mode 100644
index 0000000..cc5c24d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic158.C
@@ -0,0 +1,24 @@ 
+// PR c++/61134
+// { dg-do compile { target c++11 } }
+
+struct Base { };
+
+template <typename>
+struct Fixed {
+  typedef const char* name;
+};
+
+template <typename VT, typename... Fields>
+void New(const char* name,
+         typename Fixed<Fields>::name... field_names);
+
+template <typename VT, typename... Fields>
+void CreateMetric(const char* name,
+                  typename Fixed<Fields>::name... field_names,
+                  const Base&) { }
+
+
+void Fn()
+{
+  CreateMetric<int, const char*>("abcd", "def", Base());
+}