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

From-SVN: r197244

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

index 224c5a2fe2e3f5347df34f4a48d5fe5af1783523..6686bdcbecbfa7aa79f291552a72eebe711497a7 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-29  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        * call.c (build_java_interface_fn_ref): Likewise.
index 8468a84b285f8a3904b4515ccb8dff1ee2b8cce7..4ef4ede1621133cb4baed1bcf19d0d59967af1a5 100644 (file)
@@ -16213,10 +16213,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>() );
+}