I suppose it is nice to be able to immediately see what x is initialized to, (because it is initialized and defined at the same time) instead of looking for the corresponding assignment statement. But other than that, does initialzing x offer any other advantages compared to initializing y ??? I notice in the debugger they both seem to be treated as executable statements, so x is not initialized at compile time, but I would think it should be to improve performance (assuming not just x, but a LOT of integers were being initialized)?
generate the same code. No more and no less.
(Variables are pushed to the stack at the beginning of the function and popped at the end.) int a=0;
0041138E mov dword ptr [a],0
int b;
b=0;
00411395 mov dword ptr [b],0
Variables don't exist at compile time, so they can't be initialized then. They are pushed onto the stack at run time and initialized (or not) then.
The only way to initialize sufficient integers to make a difference is to put them in an array: int array[a_large_number]={0};
If that array is local, it's initialized every time the function passes that point. If it's global, it's included initialized in the data section of the binary and moved to memory when the program loads, so in that case, the integers are initialized at compile time.
Note that initializing an integer no larger than the biggest register in the CPU takes only 1 clock cycle (for a 2 GHz CPU, that's 0.5 ns).