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

    <tr>
        <th>Summary</th>
        <td>
            std::format create undefined-behavior [UndefinedBehaviorSanitizer] [label=c++20]
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          nathan-in-code
      </td>
    </tr>
</table>

<pre>
    
```c++
#include <format>

int main()
{
  auto const str = std::format("{0}", -1);
}

``` 

If this mini-code is compiled with “AddressSanitizer” option, an undefined-behavior is detected.
The error only occurs with **negative Integers**.

Clang++-Version = 18
Option =  -fsanitize=unsigned-integer-overflow
OS: Ubuntu 24.04 (64-bit)

example: 
```shell
clang++-18 -fsanitize=unsigned-integer-overflow  -std=c++20 format.cpp -o my_format
```
output:
 runtime error: negation of 4294967295 cannot be represented in type 'make_unsigned_t<int>' (aka 'unsigned int')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/format:1099:12
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVF2PozYU_TXOyxXIXEOABx6YZCPtw6pSp1upTyMDN8FdYyPbZGb66ysD6Y5Wq2olFAL36_icc5Heq5shaljxxIrzQS5htK4xMozSJMokvR3o0NnhvWG8ZUe-XT3Dp3jxlqFQptfLQMDE6WrdJAMTn2KEt8oEmKQyDCuGdXxXxhoAuQQLvTU-gA8OmDiDDwMTLRPt3iOWICufOCvP8R-eIMliF7GOLc_biP8gwfb8-QphVB4mZdQKHpSH3k6z0jTAqwojsE_IKs7qUzsMjrx_lkYF9Q-5R-AMdg7KmjhTGljMQFdlaEg6GuVdWRd7DhSoDzSkjLd_jATknHVgjX4H2_eL8_swbBm2hm4yqDvBZxPoRs5vr9MN80lLc9sYTf4k55U1KyVZxXj72wplfYbk6nesTJwXs0o3JGrrmdg7uau2r7HomYkWvnaLCQtgnvIcGFbHPOlU2JXgLb3JadYUMz8S6UfSmvG2_4Aqq35xNkCyCnneHYIcNj3Tfp4hsTC9v-wCfxjJeGuXMC8hOoC34BYT1LRzGvFt_FkD9go51nl9LLEuoJfG2AAdgaPZkScTaABlILzPBAzLSX6jlwfYl8DESZnVnlhGQuQ3GbMeCRCDWG4EPX_98qX9_a-Vx4cBnnb9vztGtD-zB8PL4h3DSxe9f0lThhetOoaXW98zvLxVx5djnmhllrfkZhaGlyx_JP7ws28Xw8tj6fbkx661Ga_reMPD0IihFrU8UJOVQuT8WB75YWyK8spFj3leCMp4TcWxK6sOC8LiWhbielANcswz5EUmCsx5WvVUSepq4kVRlSWynNMklU61vk-pdbeD8n6hJsuqihcHLTvSfv2IIBp6hTUa17Y4H1wTi5JuuXmWc6188N_bBBU0NT8sP_SOZKCfUls8_Y8cxTkmrGg-ejCiWJxuxhBmHwfhJWqhwrh0aW-nKI--P27J7Ozf1IdIfjyGj4xv57w3-G8AAAD__2Odl2U">