<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58814>58814</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
-Wundefined-reinterpret-cast not triggered if temporary pointer is created?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend,
clang:diagnostics
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
carlosgalvezp
</td>
</tr>
</table>
<pre>
Hi,
We find that the `-Wundefined-reinterpret-cast` warning triggers only when the dereferencing happens in the same line as the `reinterpret_cast`, but not if an intermediate pointer is created:
```cpp
void foo()
{
int a;
float b;
*reinterpret_cast<float*>(&a) = b;
auto p = reinterpret_cast<float*>(&a);
*p = b;
}
```
Repro: https://godbolt.org/z/j3f8KWWPf
I'm curious to understand if that is intended or a bug? Thanks!
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNUk2PmzAQ_TXmMkoEBkJy4JDdNGrVS1VVyrEaYABvHRvZZle7v76Ds6vNplVVZBs8b3jz9RrbPdeflZD3Ij2IdH85TwS9Mh2EEQMfBGKTrk6z6YjN1K0cKRPITY7CqkUfGIYndEaZAYJTw0DOgzX6GZ5GMpGhI0c9b9MuTiNOExkP6gJ6PBNopgb0b_GuYvx8jcFZQjMHMDaA6gENRJczdQoDwWTjFZSH1hFbOpHvr8taKOJqp-liebSqg95aIbdC7l69qrvLB_DDjIAiv7L02nJTmg82Ifd_pJvfR0-GRP4p8m-QY4DID1d_v3PgHCxMEf5frtscplvy6nBT-OX6nSZnuTcwhjD5pUnyyGuwXWN1WFs38O2F90Peb7-eTt_662S_CFmdoZ2dsjNPy8KiC-cDsmB4KlEzysfRMNCBdYA8tkHkR_gxovnlhcwSqrPNpiqroqqypKvzbpfvMAkqaKr_JbU4_FeN0SUgnSfr0D3_VQDHZHa6vilUhXFu1q0980Xrx7fXitvyQC33-ai8n4kTPZbbbVYkY13llDfFZpciVk3bYCZRElVpVu42edtRorEh7WtR3gkpW42GC973zsY2sGkR7xXCkh2M9UG1fgHLQ6JqmUqZZWmRlZkss3VOTdNUaZcVuO0LJFGkdEal10uuy5QSV8e0ubmeQa188O8geq8GQxRTYn4W2Ghd3aLT1g-oH-llSmKddSzyN404Qc0">