diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1055,6 +1055,12 @@ # define _LIBCPP_CONSTEXPR_AFTER_CXX17 #endif +#if _LIBCPP_STD_VER > 17 && defined(__cpp_constexpr_dynamic_alloc) && (__cpp_constexpr_dynamic_alloc >= 201907L) +# define _LIBCPP_CONSTEXPR_DESTRUCTOR constexpr +#else +# define _LIBCPP_CONSTEXPR_DESTRUCTOR +#endif + // The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other // NODISCARD macros to the correct attribute. #if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) diff --git a/libcxx/include/optional b/libcxx/include/optional --- a/libcxx/include/optional +++ b/libcxx/include/optional @@ -221,7 +221,7 @@ bool __engaged_; _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__optional_destruct_base() + _LIBCPP_CONSTEXPR_DESTRUCTOR ~__optional_destruct_base() { if (__engaged_) __val_.~value_type();