In C, a pointer is allowed to point to any element of the array, as well as to the last one element of the array; indicating that this behavior is undefined (C11 standard, §6.5.6, clause 8).
However, why point to one before the first element of the array is not resolved in the same way?
PS: I know that in order to circumvent the aforementioned restriction, it is sometimes possible to declare an array of 1 unit larger than necessary, then use only positions from 1 to store items and, finally, leave position 0 as a guarantee that moving the array back will be safe . However, sometimes we need to use a given array, and then the problem of pointing to one before the first element remains.
source
share