From 0429e064651d53720971f398de7124d9b46a09cc Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 29 Jan 2014 17:12:09 -0500 Subject: [PATCH] re PR c++/59989 (ICE when a template parameter pack is explicitly specified for a function template and provides a complete argument list for a template) PR c++/59989 * pt.c (expand_template_argument_pack): Correct non_default_args_count calculation. From-SVN: r207285 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 2 +- gcc/testsuite/g++.dg/cpp0x/variadic148.C | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic148.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e24a9aea8c7..858272ffc8d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2014-01-29 Jason Merrill + PR c++/59989 + * pt.c (expand_template_argument_pack): Correct + non_default_args_count calculation. + PR c++/58466 * pt.c (unify_pack_expansion): Call expand_template_argument_pack. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9be91711e55..c9c6b379bf6 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 00000000000..a4ee63533da --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic148.C @@ -0,0 +1,6 @@ +// PR c++/59989 +// { dg-require-effective-target c++11 } + +template struct X {}; +template class D, typename ...U> int test(D*); +int n = test(0); // { dg-error "no match" }