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

    <tr>
        <th>Summary</th>
        <td>
            libc++ basic_string __default_init() is worse than initializing to empty string literal
        </td>
    </tr>

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

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

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

<pre>
    See https://godbolt.org/z/n1We41MKh

I believe the issue lies here:
https://github.com/llvm/llvm-project/blob/10b1f58cba4f7e32134a8e50e97b402f81572a5a/libcxx/include/string#L1691-L1692

Initializing to an empty string literal will only initialize a `__short` representation, whereas the default constructor initializes an entire `__rep`, which requires 24 zero bytes.

```diff
-__r_.first() = __rep();
+__r_.first().__s = __short();
```
Would this solution work, or is there any reason to *always* zero the entire string memory in the default constructor?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUk0-PpDYQxT9NcSlNC8r8aQ4cujNBipKcctgjsqG6ceK2O7aZ3p5PHxkY7WaUHFZCRkZVz7yfX8kQ9NUyd1CdoXrN5BJn57ufdWD7kG-cKTc9uz-YcY7xHkCcgHqg_uom5Uw8OH8F6t-Belt84bL4_dcZ8lfIT9v6Cyo2mt8Y48yoQ1gYjeaAM3tOYmvVJ2kd50UdRncD6o15-3i93L37k8cI1CvjFFBf5Kq4VMdRyfLSsKBClPLIVc5to8qcLseiakhWMgloNX79CtRrO5plYqA-RK_tFUj8VtRt8ZJW-te_Wx21NPpd2ytGh9Ii3-7xiVsjGh3ZS4MPbQw6a56oPzoYJUKdD0OYnY9Q5-j57jmwjTJqZ4F-wkdCIMMKZuKLXEzE0dkQ_TJG578TC-vRNmrPm6rnO9T5JqLHGT3_vWjPAanEd_YO1TNyOHxvJtWvz6Qvl-3TyzD44XDRPkSgI1CLIF5xU1_3IM57M50_1x6GIez1m8dPHR_HbdsvbjETxlkHDM4sCQE-nP8rWUhWVwqeUdonJijOJuBAJ2ke8hmATpuvxGoHsV_CjW_OJ_L_xxFEn02dmFrRyoy7oj42jRAiF9ncjU3Zls1UjI0SspRqEqpStRDi2JRctcdMd5STyGuqiMojiUOVK9WKWtaTKtuSGMqcb1KbQwpoGoZszXhXiypvMyMVm7COFpHlxzYAQJQmzXdrqNVyDVDmRocYvqlEHQ13KbRAZ6AzKhn0OOymh2E3OqSQ7JenQ0Ia0qRJ-y09e3j_K7nZ4k33w7O3eghA_erxnwAAAP___HtdKA">