I have a simple program:
#include <stdio.h> void func(int i) { i = 1; printf("%d\n", i); } int main(int argc, char *argv[]){ func(0); return 0; }
and now:
gcc test.c -g -o test gdb test (gdb) b main Breakpoint 1 at 0x400543: file test.c, line 9. (gdb) run Starting program: /tmp/test Breakpoint 1, main (argc=1, argv=0x7fffffffe458) at test.c:9 9 func(0); (gdb) s func (i=0) at test.c:4 4 i =1; (gdb) pi $1 = 0 (gdb) n 5 printf("%d\n", i); (gdb) pi $2 = 0 (gdb)
The program works fine, shows "1", but why does gdb show me the value "0"?
Debian wheezy.
I noticed that on gcc-4.7, gcc-4.6. In gcc-4.4, everything is fine.
source share