[Bug libstdc++/124121] Missed optimization in initialization of std::inplace_vector with std::initializer_list
rguenther at suse dot de
gcc-bugzilla@gcc.gnu.org
Thu Feb 19 14:16:08 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124121
--- Comment #6 from rguenther at suse dot de <rguenther at suse dot de> ---
On Thu, 19 Feb 2026, redi at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124121
>
> --- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> (In reply to Richard Biener from comment #4)
> > Not sure what inplace_vector is for ...
>
> std::vector that uses internal storage, not heap allocations.
>
> So std::inplace_vector<T, N> stores between 0 and N objects of type T. It
> contains
>
> union {
> T _M_elems[N];
> };
>
> and we do not start the lifetime of the entire array, because we want it to
> contain zero objects initially. The start_lifetime_as_array call creates the
> array but not its subobjects, so we just have an empty shell that we can then
> construct individual T objects into as the inplace_vector grows.
OK, but why would you need that asm() barrier there then? What's
the semantic of a started lifetime of something with undefined state?
Wasn't std::start_lifetime_as supposed to view a defined bit pattern
as a differnet type?
More information about the Gcc-bugs
mailing list