Issue 64644
Summary C++20 std::move(ss).str() first copies and then delete the original string instead of moving it
Labels new issue
Assignees
Reporter AMP999
    https://godbolt.org/z/44Ke34fGz
```cpp
std::stringstream ss("a very long string that exceeds the small string optimization buffer length");
const char *p = ss.view().data();
std::string s = std::move(ss).str();
assert(s.data() == p); // shouldn't be a second allocation
```
In C++20 and later, moving-out-of `ss` should move the string, not make a fresh copy.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to