This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/39863 (explicit template args and variadics)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 07 Oct 2009 15:28:50 -0400
- Subject: C++ PATCH for c++/39863 (explicit template args and variadics)
tsubst_pack_expansion was failing to consider the possibility that a
mismatch in pack length could be due to incomplete deduction. I don't
think that postponing all substitution until after deduction will cause
any problems.
Tested x86_64-pc-linux-gnu, applied to trunk.
commit cb1181c7625e1123371f4bd46cd05fd592f5d9af
Author: Jason Merrill <jason@redhat.com>
Date: Wed Oct 7 12:17:04 2009 -0400
PR c++/39863
* pt.c (tsubst_pack_expansion): Don't do anything now if we
have incomplete packs of different lengths.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 6b98956..9ef3f79 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -7944,6 +7944,10 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
}
else if (len != my_len)
{
+ if (incomplete)
+ /* We got explicit args for some packs but not others;
+ do nothing now and try again after deduction. */
+ return t;
if (TREE_CODE (t) == TYPE_PACK_EXPANSION)
error ("mismatched argument pack lengths while expanding "
"%<%T%>",
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic95.C b/gcc/testsuite/g++.dg/cpp0x/variadic95.C
new file mode 100644
index 0000000..ebb04eb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic95.C
@@ -0,0 +1,17 @@
+// PR c++/39863
+// { dg-options -std=c++0x }
+
+template <typename... T>
+struct A {};
+
+template <typename T, typename U>
+struct S {};
+
+template <typename... T, typename... U>
+A< S<T, U>... > f(U... u)
+{ return A< S<T, U>... >(); }
+
+int main()
+{
+ f<int>(0.0);
+}