Commit 7c094c11 by Dodji Seketeli Committed by Dodji Seketeli

re PR c++/40239 (Aggregate initialization requires copy constructor)

Fix PR c++/40239

gcc/cp/ChangeLog:
	PR c++/40239
	* typeck2.c (process_init_constructor_record):
	value-initialize members that are are not explicitely
	initialized.

gcc/testsuite/ChangeLog:
	PR c++/40239
	* g++.dg/init/aggr5.C: New test.
	* g++.dg/init/aggr5.C: New test.

From-SVN: r158066
parent 95d938ee
2010-04-07 Dodji Seketeli <dodji@redhat.com>
PR c++/40239
* typeck2.c (process_init_constructor_record):
value-initialize members that are are not explicitely
initialized.
2010-04-07 Jie Zhang <jie@codesourcery.com>
PR c++/42556
......
......@@ -1166,8 +1166,14 @@ process_init_constructor_record (tree type, tree init)
for us, so build up TARGET_EXPRs. If the type in question is
a class, just build one up; if it's an array, recurse. */
if (MAYBE_CLASS_TYPE_P (TREE_TYPE (field)))
next = build_functional_cast (TREE_TYPE (field), NULL_TREE,
tf_warning_or_error);
{
next = build_functional_cast (TREE_TYPE (field), NULL_TREE,
tf_warning_or_error);
/* direct-initialize the target. No temporary is going
to be involved. */
if (TREE_CODE (next) == TARGET_EXPR)
TARGET_EXPR_DIRECT_INIT_P (next) = true;
}
else
next = build_constructor (init_list_type_node, NULL);
......
2010-04-07 Dodji Seketeli <dodji@redhat.com>
PR c++/40239
* g++.dg/init/aggr5.C: New test.
* g++.dg/init/aggr5.C: New test.
2010-04-07 Richard Guenther <rguenther@suse.de>
PR tree-optimization/43270
......
// Origin PR c++/40239
// { dg-do "compile" }
struct B { B() { } private: B(B const&); };
struct A { int a; B b; };
int
main()
{
A a = {0};
}
// Origin PR c++/40239
// { dg-do compile }
struct B { B() { } private: B(B const&); };
struct A { int a; B b; };
int
main()
{
A a = {};
}
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