3 ms·
$ cat test.c int main(void) {int a = 12;} $ gcc-6 test.c -o test --std=c89; ./test; echo $? 162 $ gcc-6 test.c -o test --std=c99; ./test; echo $? 0 M
by TazeTSchnitzel 9y ago
$ cat test.c
int main(void) {int a = 12;}
$ gcc-6 test.c -o test --std=c89; ./test; echo $?
162
$ gcc-6 test.c -o test --std=c99; ./test; echo $?
0
Must be a C99 thing.
- albinofrenchy 9y agoThis isn't that conclusive of a test -- uninitialized memory is 0 relatively often.
- clarry 9y agohttps://github.com/gcc-mirror/gcc/blob/4bec7283cda24b180ea7a01ae62214058a8e0020/gcc/c/c-decl.c#L9275 https://github.com/gcc-mirror/gcc/blob/4bec7283cda24b180ea7a...
- pjscott 9y agoOkay, that is conclusive. (And I'm pleasantly surprised by how readable GCC's source code is.)
- kaushiks 9y agoThis has nothing to do with memory. The x86_64 ABI returns values from functions in the RAX register.
- albinofrenchy 9y agoSure; same point applies though -- just because 0 happens to be in RAX doesn't mean it's defined behavior.