In C, does initialising a variable to it\'s own value make sense? If yes, what for?
Allow me to elaborate. In Git sources there are some examples of initialising a varia
On MacOS X 10.7.2, I tried this example - with the result shown...
$ cat x3.c
#include
int status = -7;
int main()
{
printf("status = %d\n", status);
int status = status;
printf("status = %d\n", status);
return 0;
}
$ make x3
gcc -O -std=c99 -Wall -Wextra x3.c -o x3
$ ./x3
status = -7
status = 1787486824
$
The stack space where the local status
in main()
has been used by printf()
so the self-initialization copies garbage around.