https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115846
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> --- (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>{} );