On Fri, Sep 5, 2014 at 4:19 PM, Jason Merrill <jason@xxxxxxxxxx> wrote: > 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. Huh? Doesn't placement new end the lifetime of the object that resided at the address (by re-using memory) and start lifetime of a new object at that address? So how can the new object see the storage contents of the old object? GCC certainly doesn't support type-punning via placement new. As with all methods you might be lucky with recent enough GCC versions as if they see a must-alias they don't try to disambiguate further with TBAA. Richard. > Jason >