[Bug ipa/60965] [4.10 Regression] IPA: Devirtualization versus placement new

aph at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat May 3 09:42:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60965

--- Comment #8 from Andrew Haley <aph at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #7)
> (In reply to Jan Hubicka from comment #6)
> > It is a bit
> > questionable on how precisely define what type transitions are allowed by
> > placement new.  This is quite conservative definition except for the
> > requirement that type needs to be large enough to contain the newly built
> > type.
> 
> We don't need to handle all non-PODs; arrays of (unsigned) char are special
> under the aliasing rules, so that you can construct any type of object in a
> char array and access the object representation of any type via a char
> pointer.  You can't randomly change the object stored in a buffer of any
> other type.

While it's true that we can play hardball on this one by insisting that only
char arrays should be used with placement new, it wouldn't really do any good. 
I don't think it would make any real-world code more efficient.  It makes sense
to play safe by assuming that any object of a non-polymorphic type might be
overwritten by placement new.



More information about the Gcc-bugs mailing list