diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-30 14:50:44 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-30 14:50:44 +0000 |
commit | 722a58352d6fadcad198e9eee489780f2cd636ab (patch) | |
tree | 122a7571451468aed1dc9129faf170c94c72ed72 | |
parent | e8aef9ed7f807abcffdcd096dea4f60565dfd997 (diff) | |
download | gcc-722a58352d6fadcad198e9eee489780f2cd636ab.tar.gz |
PR c++/53356
* tree.c (stabilize_init): Side effects make the init unstable.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@188019 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/tree.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/new33.C | 11 |
4 files changed, 22 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5850ff6847d..f5ba6af9096 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2012-05-30 Jason Merrill <jason@redhat.com> + + PR c++/53356 + * tree.c (stabilize_init): Side effects make the init unstable. + 2012-05-28 Paolo Carlini <paolo.carlini@oracle.com> PR c++/53503 diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 236180de7fd..897d4d7bb37 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 49d88e728b5..ae6bdaf539d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-05-30 Jakub Jelinek <jakub@redhat.com> + + PR c++/53356 + * g++.dg/init/new33.C: New test. + 2012-05-30 Richard Guenther <rguenther@suse.de> PR middle-end/53501 diff --git a/gcc/testsuite/g++.dg/init/new33.C b/gcc/testsuite/g++.dg/init/new33.C new file mode 100644 index 00000000000..18da79e7e9a --- /dev/null +++ b/gcc/testsuite/g++.dg/init/new33.C @@ -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 ()); } |