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

    <tr>
        <th>Summary</th>
        <td>
            Formatted output of zero is incorrect with std::showbase
        </td>
    </tr>

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

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

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

<pre>
    Clang behaves as if the following two were equivalent:

```
void h1(std::ostringstream& os, uint32_t num) {
 os << std::showbase << std::hex << std::setfill('0') << std::internal << std::setw(10) << num;
}

void h2(std::ostringstream& os, uint32_t num) {
  os << "0x" << std::hex << std::setfill('0') << std::setw(8) << num;
}
```

However, the standard mandates that the behaviour of `showbase` is equivalent to the using `#` with `printf` to request "alternative behaviour". There the `0x` prefix is only emitted if the value to output is non-zero.

Tested with Clang 16 (and GCC 11, 12 and 13).

The correct outputs for `h1` and `h2` given `0` are different:

```
0000000000
0x00000000
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVMGO4zYM_Rr6Qkwg0Y7tHHzYzSDtB-y9UGI6ViFLWYmOM_36Qp5km9kpsIc2CCxQ5CP59CiZlOzZM3ew_Qrb18LMMobYTW-3YPviGPq3bu-MP-ORR3PlhCahHVBGxiE4FxbrzyhLwIUjI3-f7dU49gLlF1CvoB7fWt3_q3kNtsdRA7VJ-hxafglJovXnJJHNBFRjSEB7nK2Xkv4Q9PMEtENovr6nwJAQyj2Ue_yRI41hOZrEnxwj3z4HswzWOaAWqFFAzZr-pyDrhaM37t_QC1Cr1RMqt1je24Pm9Zn_O2H6T4SfGAORugHR_0f0zqf9JZ2PQr5_fw8LXznm9vNgJDG-N7HHKa_CCWU0srrWKbJhjhgGhFo9FINaoU1P84MSVsCc8oDlelTmoMXKmM1LtF6GvCMBI3-fOUk-FuNWwcRen4oB0Qa_jXlCc06olbpl6CXyYG-5cPDuDXmyItw_5vtq3Mw5fZjlMksO88G__MUxbJ7Zf-OUUWtn73dF1wjUGt_jb_s9ap0PRhPmDV0C7T7CR8ZTiJFPcq-UcAgxdznq3GWGZYOycbZX9iuD1RUZezsMHH955dSP392-fbR_Ci_6rux35c4U3OlGNXpbq922GLuhqnt9qkrS5bHptw1r0uW2KpuqOrWnsi1sR4oqRWqrW6Wp2fQnbtum3lV1s1PcM1SKJ2PdxrnrtAnxXNiUZu5a1ehd4cyRXVqfIyLPC65OIMqvU-wy5uU4nxNUytkk6Z8sYsVxdwhxMquMd9nCgFmyLJ_1j4Nexfr0bhRzdN0ockl5nw5Ah7OVcT5uTmECOuRS9-XlEsOffBKgw9pgAjqsBP4OAAD__zOKkMQ">