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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Improve wording of `__builtin_bit_cast` size mismatch diagnostic
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            good first issue,
            clang:frontend,
            clang:diagnostics
      </td>
    </tr>

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

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

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

Clang currently prints:
```console
<source>:4:20: error: __builtin_bit_cast source size does not equal destination size (4 vs 1)
    4 | constexpr char f = __builtin_bit_cast(char, 5);
      | ^
```

while gcc prints:
```console
<source>:4:39: error: '__builtin_bit_cast' source size '4' not equal to destination type size '1'
    4 | constexpr char f = __builtin_bit_cast(char, 5);
      | ^~~~
```

I don't like that to get the sizes, I have to scan the end of the diagnostic and to understand what they mean (the first one printed is the size of the source type, the second one the size of the destination type), I have to scan the beginning of the sentence again.

We should change this to be more like the diagnostic that GCC emits.

Additionally, I think it would be beneficial to print the actual types inline in the diagnostic, e.g.
```
error: __builtin_bit_cast source type 'int' size (4 bytes) does not match destination type 'char' size (1 byte).
```
now that _does_ sound a little clunky but the exact wording is up to whoever implements this enhancement.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0lUGP4jgThn-NcykNSpyEkEMODAyf-vZJe9gjcuwi8bRjM3YFmjn0b185YWDoRqvVSishCC673jdPlW0Rgu4sYsPKr6zcJmKk3vmGWoEKvU9apy7NH4jQEx0Dy9eM7xjfdU61ztDC-Y7x3U_Gd6fv4cfJubf_s3TL0vX8vTHCdiBH79GSucDRa0tTlnnSMp0_0tngDF5H801wo5fI8m8sXxcsX_OU5WtA752PD_t9O2pD2u5bTXspAsG8AoL-iaAcBrCOAH-MwoDCQNoK0s7OccZXBZwCZIzXsyQ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