<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64644>64644</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            C++20 std::move(ss).str() first copies and then delete the original string instead of moving it
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          AMP999
      </td>
    </tr>
</table>

<pre>
    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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEU92OnDwMfZpwYw0Cw7DDBRczO5pPn6pKfYVADKQNCYrNbHefvgL2p5qbSkhA7GP7HJ9oZjt4okYdL-p4TfQiY4jN-fuPuq6TNpjXZhSZWRVnhTeFtyGYNjhJQxwU3t4U3sryGxVl_9-byq4qO6sq259unvcTFrPCizNLtH5giaQnYFZ4Uoga7hRfwQU_wJ4AMmoB-t0RGQYZCXjSzn1Ewyx2sm9abPDQLn1PERz5QUaFqLBWxWXv2wXPAt2oIyg8z6CKKzCnd0svW-s6NVr0_vkJehgWeId9nE7hTgpP6_B1yhIf0JqZoqwJf9VeK6xF5j0TdiGBx7A44xU-CbQEGpi64A1o50K3sXsQdP_938OzwovCC2agvQGnhaLCZ5jC3frhEBY5hB5UlTGrKnvvs0ZpF3MjtgJ8EJj0r7V3H4lH6ML8miamKUxd1DqhJq_q_FTmeMySsanaouzKIqe6L_MSW6KaOn0syiqrn6jTiW0wwyI75ZjnxzLP0qp9MkV31JgbzOrWqDKjSVuXOnefVgsllnmhpiqrskycbsnx5kRETy-wBdelHq9JbFbMoV0GVmXmLAt_VRErjpovWf6xLuhtXJ0RZku8aSgjeTDkSHaNQrSD9frTc9azkDYQ-neVwUqyRPd4OayMS5t2YVJ4W6d7fx3mGH5SJwpvGydWeNs4_wkAAP__IK8UpQ">