]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/56774 (G++ 4.8 reverses variadic template types during unpacking)
authorJason Merrill <jason@redhat.com>
Fri, 29 Mar 2013 18:59:35 +0000 (14:59 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 29 Mar 2013 18:59:35 +0000 (14:59 -0400)
PR c++/56774
PR c++/35722
* pt.c (unify_pack_expansion): Fix indexing.

From-SVN: r197246

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/variadic-explicit2.C [new file with mode: 0644]

index b22536262b679f4e163059d5087d604bc06f555d..58c2b149c20e7494ba5a3fc812bce644208ddcda 100644 (file)
@@ -1,3 +1,9 @@
+2013-03-29  Jason Merrill  <jason@redhat.com>
+
+       PR c++/56774
+       PR c++/35722
+       * pt.c (unify_pack_expansion): Fix indexing.
+
 2013-03-23  Jason Merrill  <jason@redhat.com>
 
        PR c++/54277
index d8b77ad0fed4434db05dbc0da3834902e3afd91e..783a8ee54c30ff56a9917219468a14757c592826 100644 (file)
@@ -15727,10 +15727,10 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms,
           arg = NULL_TREE;
           if (TREE_VALUE (pack)
               && (pargs = ARGUMENT_PACK_EXPLICIT_ARGS (TREE_VALUE (pack)))
-              && (i < TREE_VEC_LENGTH (pargs)))
+              && (i - start < TREE_VEC_LENGTH (pargs)))
             {
               any_explicit = true;
-              arg = TREE_VEC_ELT (pargs, i);
+              arg = TREE_VEC_ELT (pargs, i - start);
             }
           TMPL_ARG (targs, level, idx) = arg;
         }
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-explicit2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-explicit2.C
new file mode 100644 (file)
index 0000000..4a80745
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/56774
+// { dg-require-effective-target c++11 }
+
+template <class ... Args>
+struct mytype {};
+
+template <class T, class ... Args>
+void something( mytype<T, Args...> )
+{ }
+
+int main()
+{
+  something<int, char, bool>( mytype<int, char, bool>() );
+}