Are negative array indexes allowed in C?

That is correct. From C99 §

The definition of the subscript
operator [] is that E1[E2] is
identical to (*((E1)+(E2))).

There’s no magic. It’s a 1-1 equivalence. As always when dereferencing a pointer (*), you need to be sure it’s pointing to a valid address.

Leave a Comment