https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124121
--- Comment #14 from rguenther at suse dot de <rguenther at suse dot de> --- On Thu, 19 Feb 2026, tkaminsk at gcc dot gnu.org wrote: > 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. But do we even need that? Because to not be UB there needs to be an element construction via placement new anyway.
