is portable aliasing possible in C++?
Jason Merrill
jason@redhat.com
Fri Sep 5 14:19:00 GMT 2014
On 09/04/2014 07:11 PM, Jonathan Wakely wrote:
> Placement new might work with GCC in practice as long as the buffer is
> correctly aligned and the type being constructed does not have
> non-trivial initialization. However, my reading of the standard is
> that after the placement new, if the object's members are not
> initialized then they have indeterminate values (not the values that
> were at those memory addresses already, even though that's likely to
> be what happens in practice).
I think that's a defect in the (non-normative) note in 5.3.4/17, which
is assuming that this follows from the rule in 8.5/12. But I don't
think it does, because in this case the storage has been initialized and
therefore is no longer indeterminate.
So I think the placement new form is OK.
Jason
More information about the Gcc-help
mailing list