<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62822>62822</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Direct binding gets incorrectly overwritten
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:static analyzer,
false-positive
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
isuckatcs
</td>
</tr>
</table>
<pre>
```c++
int main() {
int x = 1024;
*((char *)&x) = 0;
if (!x) {
clang_analyzer_warnIfReached();
}
return 0;
}
```
```
warning: REACHABLE [debug.ExprInspection]
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
The statement `*((char *)&x) = 0` assigns `0` to the last byte of `x` (on a little endian system), but the analyzer incorrectly models it as overwriting the value of `x` with `0`. In reality the value of `x` remains `1024`.
See the example on [godbolt](https://godbolt.org/z/exTq3s16c).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycU01v4zYQ_TWjCxFBGn1YOujgRDEaoKft3hcUNZbY0qRLjhw7h_72gnKcxkXQAisQEjhfb968kQxBT5aog-oRqj6RC8_Odzos6g_JKiSDGy8d1Nn1KMDHeLIesq22LA5SW8AGsBWwebeL6DgLKHqRZ1hCcbMLwO0a3KhZ-uutBazPa3rRi-wj9pah92LNyM_3EMpIO_2QVprLG_kfr9Lbl_03kmqm8drPZ9hNf1_VEy_efob7iLgx_fIaYbSdoNiKb8_bp1-2j78-C6geRxqWKX0-H_2LDUdSrJ2Fqv-JXqF6_uu_nq-7XN_fZxKBJdOBLIvo_N9p15m4LkCI8eudneCZhJGBxXBhEm4ffefoA2ycFVIYzWxIkB21tCJcAtNhrf0khoXX_Btboa1y3pNicxEHN5IJQrOQQbgT-VevWdtpzThJs9yhvWqeb22l4sUKT9Jovnwd7Smu4spjXbo6Sz8P5zeiNY_O8nA0JJyNuk1uHJzhKBU2M_MxQLEF3AHu3l2p8xPg7g1wR-fvfxYhrxVgmyZjV4xt0cqEurxuyjorMa-SuSs2VTvkhVL5KAcli7rENhuU2udl0ahcJbrDDIuswizfFHVVpWXW1rKqNw1StWnzHMoscjGpMadDxE90CAt1NTaIiZEDmbD-rojrZkGxjbJr9TF0QAR8AsS9NIEeji5o1ieK5qpPfBcLPwzLFKDMjA4c_oFizYa6XkfFxKDtGOWZiMOdkDftmGyyeNP9a3Sa52VIlTsA7mLl98_D0bvfSTHgbmUUAHcrqb8DAAD__7xhWhs">