diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -982,8 +982,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void resize_and_overwrite(size_type __n, _Op __op) { __resize_default_init(__n); - pointer __data = data(); - __erase_to_end(_VSTD::move(__op)(__data, __n)); + __erase_to_end(_VSTD::move(__op)(data(), +__n)); } #endif diff --git a/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp @@ -75,7 +75,8 @@ void test_value_categories() { std::string s; - s.resize_and_overwrite(10, [](char*&, size_t&) { return 0; }); + s.resize_and_overwrite(10, [](char*&&, size_t&&) { return 0; }); + s.resize_and_overwrite(10, [](char* const&, const size_t&) { return 0; }); struct RefQualified { int operator()(char*, size_t) && { return 0; } };