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

--- Comment #8 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to 康桓瑋 from comment #7)
> (In reply to Jonathan Wakely from comment #6)
> > (In reply to Andrew Pinski from comment #1)
> > > I think it is due to:
> > > include/std/optional:     _GLIBCXX20_CONSTEXPR ~_Storage() { }
> > > 
> > > Which was done in r12-4389-g476f305b6cf11d (for https://wg21.link/p2231 ).
> > 
> > Yes, P2231 was approved as a DR against C++20, so std::optional has a
> > constexpr destructor.
> > 
> > The example works because no std::unique_ptr object needs to be destroyed,
> > but it's not related to unique_ptr at all. It works for any type:
> > 
> > Reduced:
> > 
> > #include <optional>
> > struct S { ~S() { } };
> > static_assert( not std::optional<S>{} );
> 
> It seems like ~_Storage() doesn't call _M_value.~_Up(). 
> I could be wrong.

[optional.dtor] specifies to call val->T::~T().

Reply via email to