Commit a92873f1 by Jason Merrill Committed by Jason Merrill

re PR c++/52796 ([C++11] Initialization of primitive object with 0-length…

re PR c++/52796 ([C++11] Initialization of primitive object with 0-length parameter pack fails to value-initialize)

	PR c++/52796
	* pt.c (tsubst_initializer_list): A pack expansion with no elements
	means value-initialization.

From-SVN: r186122
parent 407f43d7
2012-04-03 Jason Merrill <jason@redhat.com>
PR c++/52796
* pt.c (tsubst_initializer_list): A pack expansion with no elements
means value-initialization.
2012-04-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50043
......
......@@ -18925,6 +18925,7 @@ tsubst_initializer_list (tree t, tree argvec)
}
else
{
tree tmp;
decl = tsubst_copy (TREE_PURPOSE (t), argvec,
tf_warning_or_error, NULL_TREE);
......@@ -18933,10 +18934,17 @@ tsubst_initializer_list (tree t, tree argvec)
in_base_initializer = 1;
init = TREE_VALUE (t);
tmp = init;
if (init != void_type_node)
init = tsubst_expr (init, argvec,
tf_warning_or_error, NULL_TREE,
/*integral_constant_expression_p=*/false);
if (init == NULL_TREE && tmp != NULL_TREE)
/* If we had an initializer but it instantiated to nothing,
value-initialize the object. This will only occur when
the initializer was a pack expansion where the parameter
packs used in that expansion were of length zero. */
init = void_type_node;
in_base_initializer = 0;
}
......
2012-04-03 Jason Merrill <jason@redhat.com>
PR c++/52796
* g++.dg/cpp0x/variadic-value1.C: New.
2012-04-03 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/pack18.adb: New test.
......
// PR c++/52796
// { dg-do run { target c++11 } }
inline void *operator new(__SIZE_TYPE__ s, void *p) { return p; }
struct A
{
int i;
template<class... Ts>
A(Ts&&... ts): i(ts...) { }
};
static union {
unsigned char c[sizeof(A)];
int i;
};
int main()
{
i = 0xdeadbeef;
new(c) A;
if (i != 0)
__builtin_abort();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment