int zero1(int* i) { *i = 0; return 0; } int zero2(int* i) { *i = 0; if(i == 0) return 1; return 0; }
I tried this on GCC 4.8.1. A wonderful site for checking these things is: http://gcc.godbolt.org/
I found you can control this with -f{no-,}delete-null-pointer-checks. Apparently it's enabled by -O2.
http://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/Optimize-Options...
Regardless of optimisation, it will never be followed - it segfaults if NULL and returns normally if not.
I tried this on GCC 4.8.1. A wonderful site for checking these things is: http://gcc.godbolt.org/