commit f56f4ec3e3620b4ae4e07986a17338d607952c65
Author: Jason Merrill <jason@redhat.com>
Date: Wed Oct 19 17:21:34 2011 -0400
PR c++/50793
* tree.c (bot_manip): Propagate AGGR_INIT_ZERO_FIRST.
@@ -1879,8 +1879,12 @@ 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),
- tf_warning_or_error);
+ {
+ u = build_cplus_new (TREE_TYPE (t), TREE_OPERAND (t, 1),
+ tf_warning_or_error);
+ 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),
tf_warning_or_error);
new file mode 100644
@@ -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();
+}