diff mbox

C++ PATCH for c++/56774 (jumbled variadic template args)

Message ID 5155E448.3040706@redhat.com
State New
Headers show

Commit Message

Jason Merrill March 29, 2013, 6:58 p.m. UTC
In my patch for 35722/N2555, I forgot to adjust the index into the 
argument pack based on how many non-packed arguments there are.

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

Patch

commit 4b4cf682c8f7d15d3cf3097a2f4cf4f7f4f6acb5
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Mar 29 14:25:12 2013 -0400

    	PR c++/56774
    	PR c++/35722
    	* pt.c (unify_pack_expansion): Fix indexing.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 27e3ff8..f6101b6 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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
index 0000000..4a80745
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic-explicit2.C
@@ -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>() );
+}