Here's the simplest example I could come up with (it's functionally equivalent to the code OP pasted):
int zero1(int* i) {
*i = 0;
return 0;
}
int zero2(int* i) {
*i = 0;
if(i == 0) return 1;
return 0;
}
GCC produces the same code for these two functions. If the 'if' in zero2 is moved to the top of the function, it takes effect.I tried this on GCC 4.8.1. A wonderful site for checking these things is: http://gcc.godbolt.org/