clang-tidy - readability-misplaced-array-index — Extra Clang Tools 19.1.7 documentation

# Extra Clang Tools 19.1.7 documentation

## clang-tidy - readability-misplaced-array-index

# readability-misplaced-array-index

This check warns for unusual array index syntax.

The following code has unusual array index syntax:

    void f(int *X, int Y) {
      Y[X] = 0;
    }

becomes

    void f(int *X, int Y) {
      X[Y] = 0;
    }

The check warns about such unusual syntax for readability reasons:

  - There are programmers that are not familiar with this unusual syntax.

  - It is possible that variables are mixed up.