Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

  $ 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.


This isn't that conclusive of a test -- uninitialized memory is 0 relatively often.



Okay, that is conclusive. (And I'm pleasantly surprised by how readable GCC's source code is.)


This has nothing to do with memory. The x86_64 ABI returns values from functions in the RAX register.


Sure; same point applies though -- just because 0 happens to be in RAX doesn't mean it's defined behavior.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: