commit b2e577b5a53a4c49bb3eea682e2c1dee86c27316
Author: Jason Merrill <jason@redhat.com>
Date: Wed May 30 09:29:37 2012 -0400
PR c++/53356
* tree.c (stabilize_init): Side effects make the init unstable.
@@ -3458,7 +3458,7 @@ stabilize_init (tree init, tree *initp)
/* The initialization is being performed via a bitwise copy -- and
the item copied may have side effects. */
- return TREE_SIDE_EFFECTS (init);
+ return !TREE_SIDE_EFFECTS (init);
}
/* Like "fold", but should be used whenever we might be processing the
new file mode 100644
@@ -0,0 +1,11 @@
+// PR c++/53356
+// { dg-do compile }
+
+struct A {};
+struct B { operator const A & () const; };
+struct C { operator const A & () const; C (); };
+struct D { operator const A & () const; D (); ~D (); };
+
+A *foo () { return new A (B ()); }
+A *bar () { return new A (C ()); }
+A *baz () { return new A (D ()); }