In coerce_template_parms, if we try to pack the remaining arguments into an argument pack and that fails, we should immediately stop trying to process more arguments.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.8.
commit 1555baa24f537d0e724c53845e7ba2881df7a77f
Author: Jason Merrill <ja...@redhat.com>
Date:   Fri Feb 21 01:05:42 2014 -0500

    	PR c++/60219
    	* pt.c (coerce_template_parms): Bail if argument packing fails.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 3e464ff..0729d93 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -6808,6 +6808,8 @@ coerce_template_parms (tree parms,
           /* Store this argument.  */
           if (arg == error_mark_node)
             lost++;
+	  if (lost)
+	    break;
           TREE_VEC_ELT (new_inner_args, parm_idx) = arg;
 
 	  /* We are done with all of the arguments.  */
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic150.C b/gcc/testsuite/g++.dg/cpp0x/variadic150.C
new file mode 100644
index 0000000..6a30efe
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic150.C
@@ -0,0 +1,9 @@
+// PR c++/60219
+// { dg-require-effective-target c++11 }
+
+template<typename..., int> void foo();
+
+void bar()
+{
+  foo<0>;			// { dg-error "" }
+}

Reply via email to