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: "gdr at cs dot tamu dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 May 2007 13:30:38 -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 #84 from gdr at cs dot tamu dot edu 2007-05-18 14:30 -------
Subject: Re: [4.0/4.1/4.2/4.3 Regression] placement new does not change the
dynamic type as it should
"rguenth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| ------- 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;
This is OK as long as int and long have same alignment, sizeof, etc.
For example, that code is invalid on 64-bit platform where int has
alignment and the storage is not large enough to meet long's
requirement. This is the case only when the "operator new" is not
overloaded, but is the "standard one". The exact conditions are
so tricky to explicit that it would just be OK for us to accept it.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29286