Let's say I'm writing a C program which has:
int a = 1;
int b = 5;
int *p = &a;
Will:
int k = *(p+1);
always give k = 5
?
Formally:
Is this "continuous" property of the variables' address on the stack implementation-dependant? If not, is anything guaranteed (for example &a < &b < &p
)?
(This simple test using gcc on ubuntu gives k=5
, but other tests involving different types do not work)