https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124121

--- Comment #8 from Jan Schultke <janschultke at googlemail dot com> ---
During runtime, I don't think you need std::start_lifetime_as in the first
place.

Can't you just use
std::launder(reinterpret_cast<T*>(reinterpret_cast<char*>(_M_elems) + offset))
to access elements? Use placement new to start their lifetime, and use launder
at a byte offset to access them.

This should also be well-defined when transitioning from compile-time to
runtime. An inplace_vector created during compile time will have elements in
the union. It should be possible to access those elements at runtime at the
correct byte offset.

The only question is whether you're allowed to do char* arithmetic on the bytes
of a union with no active alternative. I suspect we don't have wording covering
this, but it would work everywhere in practice.

Reply via email to