Re:What Every C Programmer Should Know About Undefined Behav...
by lmm on Thursday January 05, 2017 @09:52AM
(#13327490)
> 1. What's the proper way to do a NULL check? In the first example, they show how a NULL check could be optimized away, but I didn't see where they explained how to do it the right way. I might have just missed it though.
You need to not do * p at all if p is NULL (i.e. move the "int dead = * p" after the early return).
You need to not do * p at all if p is NULL (i.e. move the "int dead = * p" after the early return).