tsubst_copy_and_build was assuming that substituting into a pack
expansion would always produce a vector of elements, which is not true
if the template arguments are still dependent.
Tested x86_64-pc-linux-gnu, applied to trunk.
commit 3bc57a5e66cd7a4e6e9a77900249db0bf193456b
Author: Jason Merrill <ja...@redhat.com>
Date: Mon May 9 17:13:55 2011 -0400
PR c++/48736
* pt.c (tsubst_copy_and_build): Handle substitution of a pack
expansion producing another expansion.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index f6392d6..5e24977 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -13250,7 +13250,8 @@ tsubst_copy_and_build (tree t,
ce->value = tsubst_pack_expansion (ce->value, args, complain,
in_decl);
- if (ce->value == error_mark_node)
+ if (ce->value == error_mark_node
+ || PACK_EXPANSION_P (ce->value))
;
else if (TREE_VEC_LENGTH (ce->value) == 1)
/* Just move the argument into place. */
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic108.C
b/gcc/testsuite/g++.dg/cpp0x/variadic108.C
new file mode 100644
index 0000000..3ad5af4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic108.C
@@ -0,0 +1,10 @@
+// PR c++/48736
+// { dg-options -std=c++0x }
+
+template<class T>
+T&& create();
+
+template<class T, class... Args,
+ class = decltype(T{create<Args>()...}) // Line X
+>
+char f(int);