When a variable with a pack expansion initializer expands to a null list, we build a value-initialization to use for initializing that variable. We need to mark it as direct-initialization to avoid problems with move-only types.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 250c45ded01f6e903995f93dccc4284e09e423f9 Author: Jason Merrill <ja...@redhat.com> Date: Sat Apr 15 00:12:27 2017 -0400 * pt.c (tsubst_init): Set TARGET_EXPR_DIRECT_INIT_P. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 862c2c2..f8436b3 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14413,6 +14413,8 @@ tsubst_init (tree init, tree decl, tree args, complain); if (TREE_CODE (init) == AGGR_INIT_EXPR) init = get_target_expr_sfinae (init, complain); + if (TREE_CODE (init) == TARGET_EXPR) + TARGET_EXPR_DIRECT_INIT_P (init) = true; } return init; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-init2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-init2.C new file mode 100644 index 0000000..8d5228c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-init2.C @@ -0,0 +1,20 @@ +// { dg-do compile { target c++11 } } + +struct MoveOnly { + MoveOnly() = default; + MoveOnly(MoveOnly const&) = delete; + MoveOnly(MoveOnly&&) = default; +}; + +struct StoresMoveOnly { + StoresMoveOnly() {} + ~StoresMoveOnly() = default; + + MoveOnly value; +}; + +template <class ...Args> void test(Args... args) { + StoresMoveOnly s(args...); +} + +int main() { test(); }