C++ Logo

SG12

Advanced search

Subject: Re: [ub] launder and aliasing
From: Robert Haberlach (rh633_at_[hidden])
Date: 2016-02-28 05:18:26


On 2/26/2016 9:46 PM, Richard Smith wrote:
> I don't think that is the right interface for such functionality. No matter what you do with the pointer, if you create a situation where an int*
> and a float* can simultaneously exist and both can be used to load or store the same memory, you destroy TBAA.
I see.

I take it that the placement new in your example is necessary to apply [basic.life]/7, as we wouldn't otherwise be able to obtain a pointer actually
pointing to the last created object of type T (or more fundamentally, a memcpy does not eo ipso create an object of a different type in the target
memory location). However, this requires default constructability. Is there a way to "inject" the new type without necessitating a default constructor
call?

IIRC there was a paper suggesting a construct that performs such vacuous "initialization" (demonstrated using __cookie__ as an initializer), but I
can't find it at the moment.

Also, I don't see the point of p->~U(). Isn't U::~U trivial by assumption?


SG12 list run by herb.sutter at gmail.com