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

--- Comment #7 from Tomasz KamiƄski <tkaminsk at gcc dot gnu.org> ---
I do not see how triviality of the types matters here, as indicated by constant
evaluator, 
the expression used to create elements is UB is _M_elems is not within
its-lifetime:
new (_M_elems[2]) _Tp()

We could always zero-out the array (would use memset), but again this will have
no trivial runtime cost for the cases where capacity is large. I think we
should avoid doing that if possible.

Maybe we could completly remove the start_lifetime_as_array, and assume that
compilers do not optimize around this UB. I think that should be true, as types
like inplace_vector very popular in the wild, and precede inplace_vector.

Reply via email to