diff mbox

C++ PATCH for c++/59989 (ICE with variadics)

Message ID 52E97C7A.2030605@redhat.com
State New
Headers show

Commit Message

Jason Merrill Jan. 29, 2014, 10:11 p.m. UTC
We counted the pack and all the elements of the pack, giving us a final 
count one too high.

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

Patch

commit b75c08746dc30ac50e908e8d520042f4157281f9
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jan 29 16:41:23 2014 -0500

    	PR c++/59989
    	* pt.c (expand_template_argument_pack): Correct
    	non_default_args_count calculation.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 9be9171..c9c6b37 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -3471,7 +3471,7 @@  expand_template_argument_pack (tree args)
           for (i = 0; i < num_packed; ++i, ++out_arg)
             TREE_VEC_ELT (result_args, out_arg) = TREE_VEC_ELT(packed, i);
 	  if (non_default_args_count > 0)
-	    non_default_args_count += num_packed;
+	    non_default_args_count += num_packed - 1;
         }
       else
         {
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic148.C b/gcc/testsuite/g++.dg/cpp0x/variadic148.C
new file mode 100644
index 0000000..a4ee635
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic148.C
@@ -0,0 +1,6 @@ 
+// PR c++/59989
+// { dg-require-effective-target c++11 }
+
+template<typename T> struct X {};
+template<template<typename...> class D, typename ...U> int test(D<U...>*);
+int n = test<X, int>(0);	// { dg-error "no match" }