Consider this defnition:
int x[] = {5,4,3,2,1};
char y[] = {9,8,7,6,5};
Because sizeof(*x) = 4 and sizeof(*y) = 1
GDB will calculate result of x with alignment value of 4 and result of y with alignment value of 1,
therefore we will have such output in GDB:
p (int)*(x+1) --> 4
p (char)*(y+1) --> 8
Eventually, x will be added by 4 and y will be added by 1 then do type casting.
No comments:
Post a Comment