re PR c++/50793 (G++ doesn't value-initialize all members of non-trivial type in default argument)

PR c++/50793
	* tree.c (bot_manip): Propagate AGGR_INIT_ZERO_FIRST.

From-SVN: r180223
This commit is contained in:
Jason Merrill 2011-10-19 18:21:15 -04:00 committed by Jason Merrill
parent 7d5888b7ca
commit 2c777ba293
4 changed files with 47 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2011-10-19 Jason Merrill <jason@redhat.com>
PR c++/50793
* tree.c (bot_manip): Propagate AGGR_INIT_ZERO_FIRST.
2011-10-13 Jason Merrill <jason@redhat.com>
PR c++/50618

View File

@ -1536,7 +1536,11 @@ bot_manip (tree* tp, int* walk_subtrees, void* data)
tree u;
if (TREE_CODE (TREE_OPERAND (t, 1)) == AGGR_INIT_EXPR)
u = build_cplus_new (TREE_TYPE (t), TREE_OPERAND (t, 1));
{
u = build_cplus_new (TREE_TYPE (t), TREE_OPERAND (t, 1));
if (AGGR_INIT_ZERO_FIRST (TREE_OPERAND (t, 1)))
AGGR_INIT_ZERO_FIRST (TREE_OPERAND (u, 1)) = true;
}
else
u = build_target_expr_with_type (TREE_OPERAND (t, 1), TREE_TYPE (t));

View File

@ -1,3 +1,8 @@
2011-10-19 Jason Merrill <jason@redhat.com>
PR c++/50793
* g++.dg/init/value9.C: New.
2011-10-15 Janus Weil <janus@gcc.gnu.org>
PR fortran/50659

View File

@ -0,0 +1,32 @@
// PR c++/50793
// { dg-do run }
struct NonTrivial
{
NonTrivial() { }
};
struct S
{
NonTrivial nt;
int i;
};
int f(S s)
{
s.i = 0xdeadbeef;
return s.i;
}
int g(S s = S())
{
return s.i;
}
int main()
{
f(S()); // make stack dirty
if ( g() )
__builtin_abort();
}