[Bug libstdc++/29286] [4.0/4.1/4.2/4.3 Regression] placement new does not change the dynamic type as it should

gdr at cs dot tamu dot edu gcc-bugzilla@gcc.gnu.org
Fri May 18 13:30:00 GMT 2007



------- 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



More information about the Gcc-bugs mailing list