diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -2289,10 +2289,20 @@ _NOEXCEPT_(is_nothrow_move_assignable::value) #endif { - __clear_and_shrink(); - __r_.first() = __str.__r_.first(); - __move_assign_alloc(__str); - __str.__zero(); + if (__is_long()) { + __alloc_traits::deallocate(__alloc(), __get_long_pointer(), + __get_long_cap()); +#if _LIBCPP_STD_VER <= 14 + if (!is_nothrow_move_assignable::value) { + __set_short_size(0); + traits_type::assign(__get_short_pointer()[0], value_type()); + } +#endif + } + __move_assign_alloc(__str); + __r_.first() = __str.__r_.first(); + __str.__set_short_size(0); + traits_type::assign(__str.__get_short_pointer()[0], value_type()); } template