Issue 132791
Summary [clang-tidy] fcppcoreguidelines-pro-bounds-pointer-arithmetic fails to detect a case of pointer arithmetic
Labels
Assignees
Reporter adesitter
    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]`).

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to