The compiler and optimizer is entitled to elide certain checks or simplify code under the assumption that a pointer being dereferenced should not be null, and this could lead to dangerous things.
Here's an artificial example:
int x = 0;
int *p;
if (...some condition...)
p = &x;
else
p = NULL;
print(*p);
The compiler is allowed to simplify the code to: int x = 0;
int *p;
p = &x;
print(*p);
It's because the 'else' branch must cause a null pointer dereference, so that case can be legally ignored.