Consider this mini example:
void myfunc (int * p) {
int t = *p;
if(p == NULL) { return;}
*p = t + 1;
}
Accessing p before null check is undefined, and causes compilers to deduce that the null check isn't required. It can therefore be stripped, which most programmers would find very surprising.Edit: yes, the replies are right, I meant to dereference *p rather than just copy the pointer. Fixed and somewhat simplified.
I was trying (badly) to remember this example: http://blog.llvm.org/2011/05/what-every-c-programmer-should-...