This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/29286] [4.0/4.1/4.2/4.3 Regression] placement new does not change the dynamic type as it should
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 May 2007 08:45:56 -0000
- Subject: [Bug libstdc++/29286] [4.0/4.1/4.2/4.3 Regression] placement new does not change the dynamic type as it should
- References: <bug-29286-10053@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #81 from rguenth at gcc dot gnu dot org 2007-05-18 09:45 -------
Yes, both testcases are valid and are using placement new. Note the loop
is only to confuse the optimizers enough to re-order the stores and produce
a miscompilation. Note the loop runs exactly once, and in essence we are doing
int *p = XXX; /* integer memory */
*p = 0;
long *q = new (p) long;
*q = -1;
and the compiler is re-ordering the stores which is wrong. *p and *q need to
alias because of the placement new.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29286