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

    <tr>
        <th>Summary</th>
        <td>
            Clang's static analyzer should complain about reflexive assignment
        </td>
    </tr>

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

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

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

<pre>
    In #c on the libera IRC network, someone said:

> `int fd = fd;` this cost me about half an hour today

I wrote a small test program:

```
int main() {
int a = 0;
a = a;
return 0;
}
```

Both `clang --analyze /tmp/same.c` and `clang-tidy  /tmp/same.c --` do not report any issues. However, copy and pasting that into PVS Studio via godbolt (an extra new line at the end might be needed) generates a warning:

https://pvs-studio.com/en/pvs-studio/godbolt/

https://pvs-studio.com/en/docs/warnings/v570/

It would be nice if Clang's static analyzer would complain about this as well since anything doing this is probably doing something wrong.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE2PpDYQ_TXmUqLlNg3MHDhkZoIytygr5V7gApwYG9lFs-TXR6bJfow2h5WQwcWjqvzeKzBGMzqiRpQvonzLcOXJhybs6LPO6715dyBU0YN3wBOBNR0FhPc_XsERbz78LdQrRD-TdwQRjRbFL0K-CfnfWvwKopLGMQwaRPEGgxbFi6gk8GQi9D4yzATY-ZVhQjsAOpj8GoC9xv3bXO-wBc8ECHFGa4EpMizBjwHnj2UreV7HNpWf0TihnoR6BlG_fI3j0ZVMTR2xxx6_7APxGtw3AFG__bDIY33xPKUT9xbdCHmODu3-D4FQLc-LUG3EmS59IgCd_oLM2egdPqIgzxNQe3CeIdDiAwO6HUyMK8UL_OY3ulNIIvR-2Y-UC0Y2bgSekME49vD7n5_gE6_aeLgbhNHrzlsGoZ7QAX3mgOBoA2scAfIhNDkNsxknho7AEWnSibmRHAVkioCwYXDGjR-Yn5iXmGKqFapd7jGPR-VL72ehWnLfRYVqz24S_ifTaN9Hodqzj_R4L2v5IdE7w-ZXq49zmJ7ADPCaGBeqjhAZ2fRwihROaO_nxaJxpysPo2KEjayFaFxPSQOeEsnaP6g2EUxMZuyws_sZTnPxgG3Bu_GS6abQz8UzZtRcq7ouC_ksq2xqqroqK3kd9LWiQV5xqHXdId0kdiUVpcpMo6QqpFK1krcnVV2ut6drV1YDFTc9dFiIm6QZjb1Ye58vPozZYZGmusqiyCx2ZOMx5EolqY-XQqk086FJ3-TdOkZxk9ZEjl-zsGFLzf8TFqcfMRZosPTZ3AkeP5iZHGdrsM33so6Gp7U7JU0lz1u-BP8X9ckTD6ML1R4H-TcAAP__v-h7bg">