On Fri, 29 Aug 2025, Ville Voutilainen wrote:

> On Fri, 29 Aug 2025 at 10:40, Richard Biener <[email protected]> wrote:
> > So, is std::start_lifetime_as<T> a thing on readonly objects?
> 
> Yes. It has a const void* overload. From a language-conceptual
> perspective, there's nothing odd about creating
> a const buffer from bit soup and then starting the lifetime of an
> object of another type in that buffer.
> 
> From a language perspective it's not a store. It just tells the
> language that an object of type T resides in that storage.

I fear we have nothing to implement that in all cases at this point
unless the C++ standard somehow forces provenance on the pointers,
so that

 const short x[8] = {};
 std::start_lifetime_as<const double> (x);
 const double *p = (const double *)x;
 ... = *p;

is UB.

Richard.

Reply via email to