In C, given
char arr [10];
uint32_t i = -1;
char * p = &arr [1];
does (p + i) overflow/undefined or equals to &arr [0]? why the pointer arithmetic rules in C standard(6.5.6.8) so confusing?
The language defines pointer can do +, -, +=, -= operations with any integer type, what will happen when pointer add a negative int value? What if the representation of the pointer is 4 bytes but the integer operand is int64_t?
The C99 standard defines pointer arithmetic in array index term(6.5.6.8), according to my understanding, it states:
char * ptr = …;
char * new_ptr = ptr + int_expr;
assert( (new_ptr - ptr) == (int_expr) );
what’s the reason for the obscured, indirect definition?