M
Mantorok Redgormor
Are negative values used as an index for an array valid or is this
illegal and if it is illegal where does it state it in the standard?
The only way I can see where a negative value can be used is if you
assign an address to a pointer to the type of array where that address
is not the lowest address of the array(the address the array name
decays to)
Something like:
int *foo;
int bar[10] = {0};
foo = bar+1;
printf("%d\n", foo[-1]);
would be perfectly legal?
However, bar[-1] would not?
illegal and if it is illegal where does it state it in the standard?
The only way I can see where a negative value can be used is if you
assign an address to a pointer to the type of array where that address
is not the lowest address of the array(the address the array name
decays to)
Something like:
int *foo;
int bar[10] = {0};
foo = bar+1;
printf("%d\n", foo[-1]);
would be perfectly legal?
However, bar[-1] would not?