| 1 |
.. title:: clang-tidy - readability-misplaced-array-index |
| 2 |
|
| 3 |
readability-misplaced-array-index |
| 4 |
================================= |
| 5 |
|
| 6 |
This check warns for unusual array index syntax. |
| 7 |
|
| 8 |
The 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 |
|
| 16 |
becomes |
| 17 |
|
| 18 |
.. code-block:: c++ |
| 19 |
|
| 20 |
void f(int *X, int Y) { |
| 21 |
X[Y] = 0; |
| 22 |
} |
| 23 |
|
| 24 |
The 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 |
|