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

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to 康桓瑋 from comment #7)
> It seems like ~_Storage() doesn't call _M_value.~_Up(). 
> I could be wrong.

Because the _Storage union doesn't know if there is an active member or not, so
it doesn't know if anything needs to be destroyed.

It's done in _Optional_payload_base::_M_destroy().

(In reply to 康桓瑋 from comment #8)
> [optional.dtor] specifies to call val->T::~T().

But only if it has a contained value. You can't destroy something that doesn't
exist.

Reply via email to