I am observing this strange behavior with uninitialized pointers.
As you can see from the following examples, sometimes it prints a NULL
value while others it prints a valid address, in an alternating fashion.
Why is this happening?
Code:
int *i;
printf("%p\n", i);
Output:
(nil)
Code:
int *i;
printf("%p\n", i);
int *j;
printf("%p\n", j);
Output:
0x7fff2d0c1b50
(nil)
Code:
int *i;
printf("%p\n", i);
int *j;
printf("%p\n", j);
int *k;
printf("%p\n", k);
Output:
(nil)
0x7fffda5284b0
(nil)
Code:
int *i;
printf("%p\n", i);
int *j;
printf("%p\n", j);
int *k;
printf("%p\n", k);
int *l;
printf("%p\n", l);
Output:
0x400510
(nil)
0x7fff6d7089c0
(nil)
Code:
int *i;
printf("%p\n", i);
int *j;
printf("%p\n", j);
int *k;
printf("%p\n", k);
int *l;
printf("%p\n", l);
int *m;
printf("%p\n", m);
Output:
0x357521cbc0
0x400520
(nil)
0x7fff715849e0
(nil)
System: x86_64 x86_64 x86_64 GNU/Linux (x86_64-redhat-linux)
Compiler: gcc version 4.1.2 20080704 (Red Hat 4.1.2-52)