Differences in the initialization of the EAX register when calling a function in C and C++
There is a curious difference between assemblies of a small program, when compiled as a C-program or as a C++-program (for Linux x86-64). The code in question: int fun(); int main(){ return fun(); } Compiling it as a C-program (with gcc -O2 ) yields: main: xorl %eax, %eax jmp fun But compiling it as a C++-program (with g++ -02 ) yields: main: jmp _Z3funv I find it puzzling, that the C-version initializes the return value of the main-function with 0 ( xorl %eax, %eax ). Which feature of the C-language is responsible for this necessity? Edit: It is true that, for int fun(void); the is no