<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/132791>132791</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] fcppcoreguidelines-pro-bounds-pointer-arithmetic fails to detect a case of pointer arithmetic
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
adesitter
</td>
</tr>
</table>
<pre>
Considering
```
#include <vector>
auto f1(std::vector<int*> const& ind, int i, int j)
{
// **Not** detected by cppcoreguidelines-pro-bounds-pointer-arithmetic
return ind[i][j];
}
auto f2(std::vector<int*> const& ind, int i, int j)
{
auto i0 = ind[i];
// Detected by cppcoreguidelines-pro-bounds-pointer-arithmetic
return i0[j];
}
```
```
⯠clang-tidy --version
LLVM (http://llvm.org/):
LLVM version 20.1.0
Optimized build.
⯠clang-tidy "--checks=-*,cppcoreguidelines-pro-bounds-pointer-arithmetic" -quiet m.cpp --
12 warnings generated.
/tmp/m.cpp:11:10: warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]
11 | return i0[j];
| ^
```
clang-tidy fails to spot the issue in the first case (`ind[i][j]`).
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVEGTqzYM_jXioiFj7ADhwIGEzem1vfVObEG8JTa1xXa2v74DIS_b1-1hZ56HwbKRLH3fh9zFaAdHVEN-hLxNupmvPtSdoWiZKSQXb97rk3fRGgrWDSAaKMT2iAaksk6PsyEEdXojzT6AegHRdDN77DOQh8gGVAOqeXw-WccgG1AvqL2LDLJA6wzIE1rHaB_GK8hqyVEeQTSIIM8gz7hEyuZXz3cDDTFpJoOXd9TTpH2gYbaGRusoplPw6cXPzsR08tYxhbQLlq83YqvXYwPxHNxaQH60kLeQH1-XSR3X5O13MPIngllPtAJBtR9Tq39BbX8SNPEJpB-F_Gi_SKhaaM6ox84NKVvzjmn6RiFa70A03779_guCPFyZp4WNtdpxfLvtfBjWVbVsLyWsrlskSrHLdmLd_21ie7N_L9hmO5rdVtFnmUHKNNVX0n9EUG26yn76Kh1SYvrnbInxttPThGkKoskk_tUFZ90QcSBHoWO6lyLPfJtAnldnUE2WLS8BqnlELKbx6DzjHAm3lPhMiZAfv1pl3q7kYJYhlCf8PwVxHXePbUD-8qOKovlAYt_ZMSJ7jJNn5CuhjXEmtG5d9DZERt1FWnSFQvy3HQoBslrISUytTKWqLqE6K_fyoA5VIZJr3Rf7rM8vQh_2QvZK5WVPl0Jr0UmzL6lIbC2FzIWS-6zMCyF2JFQh8n1FZU9ZWRjYC7p1dtw9fqZkrbLOlCyrLBm7C43xcVeFevFKL_MQYS9GGzk-49jyuN5qTw4gb7H_oiJP3u7XDHZ3knz_ieLJHMZ66Yn4vSkGy9f5stP-tnXINi1ZX0kzyPOKMII8byDfavlPAAAA__9d5LlY">