https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124121
Tomasz Kamiński <tkaminsk at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tkaminsk at gcc dot gnu.org
--- Comment #10 from Tomasz Kamiński <tkaminsk at gcc dot gnu.org> ---
> 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.
That will insert optimization barrier (what launder does) into every access,
preventing even more optimizations, like constant propagating values between
constructor/assignment and load.