xref: /llvm-project/clang-tools-extra/docs/clang-tidy/checks/readability/misplaced-array-index.rst (revision 6e566bc5523f743bc34a7e26f050f1f2b4d699a8)
1.. title:: clang-tidy - readability-misplaced-array-index
2
3readability-misplaced-array-index
4=================================
5
6This check warns for unusual array index syntax.
7
8The following code has unusual array index syntax:
9
10.. code-block:: c++
11
12  void f(int *X, int Y) {
13    Y[X] = 0;
14  }
15
16becomes
17
18.. code-block:: c++
19
20  void f(int *X, int Y) {
21    X[Y] = 0;
22  }
23
24The check warns about such unusual syntax for readability reasons:
25 * There are programmers that are not familiar with this unusual syntax.
26 * It is possible that variables are mixed up.
27
28