<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115935>115935</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc++] `std::format` reads past the 0 terminator in `char[N]` arrays
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Fulgen301
</td>
</tr>
</table>
<pre>
[Reproducer](https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAMzwBtMA7AQwFtMQByARg9KtQYEAysib0QXAGx8BBAKoBnTAAUAHpwAMvAFYTStJg1DIApACYAQuYukl9ZATwDKjdAGFUtAK4sGIAMxmpK4AMngMmAByPgBGmMQS/qQADqgKhE4MHt6%2BAUGp6Y4CYRHRLHEJXEl2mA6ZQgRMxATZPn6Btpj2RQwNTQQlUbHxibaNza25HQrjA%2BFD5SNVAJS2qF7EyOwc5v7hyN5YANQm/m7IM8ThwKfYJhoAgrv7h5gnZ/zELEwEt/dPZj2DAOXmOpzcySugj%2Bj3%2B4QIR2%2B4Qgy3%2BJgA7FZHkccUdkAgmkcYl4qFR4iYAKwWCkaSkAEVOWIeuKOM3QIBAbBYSgIEGJpPipCOGlUbjcQvSAC9MKgqHySWTiMtUf4mSy2RziIZgJgFBy0MkAJ4QcxmAASXVoqCOAHUSLR0KahfzFSqmf8WUwvEQjsRdV5aAjTnTWQR2SBPt9eaaMVZ0QyzEEiQr4m6PbiNSBIfDaAwTYm/QoAwipewTpiMXSJQRiPQ/OW4wmk4XiwA6Uso6vhy51iAtwOt5AAfUuKOVjPTOMz2cEufzZn7BBADcrTt9/sDadh8Y4q1onApvD8HC0pFQnDc1msrPWmzeux4pCXJ93qwA1iAACz%2BVuAgCcFKSBSn6fmYAAc6IUlU%2BicJ%2BR6aLw54cLweoaE%2BCGrHAsAwIgKCoCwyR0IKFAQGgBFEQkBzakONZeA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GyHQdbU8uggj2yYI7LSzs7ERM9t7b0Rw/YZMDprbJYcIAR1HsQaOgQvGM1WEnFOIx06wSziAbmzTkJRMLqMnxZg/ytn8RoTZYENBN0/PXfwpUW5tw9gs%2BOTMM5mGOXnU53i/LpGcJ%2BIAA%3D%3D%3D)
If one passes a fixed size `char` - array containing a 0-terminated string to `std::format`, the entire array minus one character is added to the result, instead of just the part until the null terminator. This not only seemingly violates [format.formatter.spec]/2.2, but also doesn't match the behavior of MS-STL or libstdc++. (And only formatting 49 characters out of a 50 character array seems buggy anyway.)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsVkmzsjCz_jWcDfWeggioi7MIMyIigwPuAgSIjBIQ8Nff0vPe-71169uktbv66ZHkQZSSvMH4hxFlRlS_0DgUbf-jj1WOmxXHf8VturyNPu76Nh0T3DOiyoBNMQwdZVaQAToD9LxN47Yavts-_yhWL2YF3WifF1CXH6noKTOMpmMkO0ot-6m8hzrvKQlER02BzmuSBweuoTfpg-PJC_TzrT14kQYXSmLOu0Jj3sgytFu5CSE8QbOboPOEehQGwy7nVQt2UImgN0ZjWW1vMJxU-55CQz8N0BaoYUFnrjtbgE6TOzWUl2MuG7XjBQzQHx5UH7ldaIJjDhIDRCDDk9FJkaBEvunvTW131SpQQ-nm5b4zw_B2bCR56O7A96ZD6HnVKTZnEqPDCwHR9Po7_KDoqhgcznAXgIe-1hZ3SsTnulgOYgQPXs0AvV5bziYsJjuLdkUL8_65LsS8uTFAf2l7bdIGBujp8XYHKnSvtdu9kiUY8_sH_b76CMGzfPD3V7786nY5XOs3s0ySU1rCvC6TqBIeui-QCNrTRSlRUELt7F4sPNqus_IsGcZyFOSWZuy6I-kU16hO8T3xngFUto6dP8wluITEGU6ZUAcL8F_EuuW7XJcXzinhTvCSuYYwuJ7bh-JC8xTsfc5GRfbSg0edbS6n6al5d-qnZxHBe9iEF88HgXwcthgh53zjvOWlacTrhVo6xuQQyFamIjiF0btRXgsn0uEp7IhzDXae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