<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/110551>110551</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
bugprone-sizeof-expression new false positives in pre20240924 clang-tidy, not reported by pre20240917
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
douzzer
</td>
</tr>
</table>
<pre>
We're seeing a slew of new false positives of this form:
```
CC wolfcrypt/src/src_libwolfssl_la-dilithium.lo
/tmp/tmp.4346_11739/wolfssl_test_workdir.26775/wolfssl/wolfcrypt/src/dilithium.c:5534:21: warning: suspicious usage of 'sizeof(...)' in pointer arithmetic; this scaled value will be scaled again by the '+' operator [bugprone-sizeof-expression]
5534 | s2 = s1 + params->s1Sz / sizeof(*s1);
| ^ ~~~~~~~~~~~
/tmp/tmp.4346_11739/wolfssl_test_workdir.26775/wolfssl/wolfcrypt/src/dilithium.c:5534:21: note: '+' in pointer arithmetic internally scales with 'sizeof(sword32)' == 4
```
These weren't reported by `pre20240917`.
A workaround with `pre20240924` is to parenthesize thusly:
```
s2 = s1 + (params->s1Sz / sizeof(*s1));
```
These parentheses should not be necessary -- the `/` has higher precedence than the `+` and the incumbent code pattern is quite common.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVE-PqzYQ_zSTyygI7ADLgUOyefkCrdTjyuAJuDU29ZhNs4d-9soJ7yWv2pV6qxUZMtgz8_tjK2YzOKIWygOUx41a4uhDq_3y8UFh03l9bX8jEHUgZCLjBlTIli7oz-jogmdlmXD2bKJ5J07hOBrGsw8TyD3kR8j3UOXr7_YX8fUVL96e-3CdI4gTh_4-v1nTpQ_M9s2qrTbWxNEsU2b9mkmc4jTf52wnd9VbUdSyAXH6vi0Sx7eLD39oEzJR1XX5-Li-_Vz2UaQHuS9LuQO5FwXIPV5UcMYN6ZUXnk1v_MK4sBooAQVRs_kgfwbxkmUZiAZEjcbh7I2LFFAFE8eJoulBHu68cK8saXxXdiG8GGuxo-9BNSjjsLtiHCklB3FICf1MQUUfEMpDtwxz8I6298Jb-msOxGy8g_J4pyghQKhf8XmwQJBH5AJBHHBWQU28BfmNi18-EMQJfwABseciQZGHlfJ_pfo-oPyGfz_G_6GP85HS88HVp-TjLeCUtdc71YwXE8ef9OOLD1qKVUOQx0TX7lP7_joSE14okANRRww0-xBJJ-WgyudAIhe7vClqqPJsTXGb95iAq-AXp9cWntaLHVQ5Gsbok0Lk4kipP4zjwvb69Wn6SmYQL_9J6WexP4P6oxli5NEvVifmk3Ed9cSswhW327trqxzEKeEYFeNohpECzoF60uT6BEW5x8JDWqicvkWM65epIxex9zoVjUm0xMefi4mEvZ8m71Y-N7qVupGN2lBb1KKuRSGKejO2nd7pvJKSdoKKTqhGq6YqZNVUZV3WRbMx7Z1tmRcvUsoy03WtJVVSnZuibl5q2OU0KWMza9-nzIdhY5gXaosiL8tiY1VHlm_3pRC9VW7YRqOvIES6P0Obdm27ZWDY5dZw5EeeaKKl9usj_OmFmhz9cAg-V3y9yfBsvyfvbZZg2zHGmZNxxAnEaTBxXLqs9xOIU-pqfWzn4H-nPh25G1QGcVrRvrfinwAAAP__FqXlRA">