This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Strict aliasing plus placement new / explicit destructor call


Justin Lebar <justin.lebar@gmail.com> writes:

> I'm surprised that everyone here is in agreement that the code I
> posted obeys the strict aliasing rules.  My understanding -- and
> perhaps this is totally wrong -- is that the "may alias" relation
> isn't transitive.  That is, although char* may alias anything, T* may
> not alias char*.  Perhaps this explains the error I'm getting.

It's valid because the C++ aliasing rules are not the same as the C
aliasing rules.  In C++, if you use placement new, it changes the
dynamic type of the memory location.  The memory location must then be
accessed using that type, until a new placement new is run, or the
memory is modified using the original type.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]