if (NULL != s) { s->a = 1; }
s->b = 1;
then GCC may optimize away the NULL check because referring to s->b after the block protected by the NULL check indicates that the NULL check is superfluous. I this case, this is actually true, but in cases that involve aliasing that is not detected by dataflow analysis, there might be circumstances where the NULL check is required. Discussion of something related is here[0]; my example might not be very good.
An even more insidious case is [1](strong language), where manual overflow checks are optimized out because the overflow technically invokes UB.
Compiler optimization gone wild.
[0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71892 [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30475