On 18.12.2013 10:46:40, Richard Braun wrote: > On Wed, Dec 18, 2013 at 10:37:03AM +0100, Marin Ramesa wrote: > > Compiler needs to check both !a and !b. In order to evaluate !b it > > must evaluate b. So when the code path is that when entry is a null > > pointer, the evaluation of b results in a dereference of a null > > pointer. > > No, that's wrong. The && and || operators are guaranteed to be > evaluated left-to-right, and yield if the first operand compares > equal to 0. And that's exactly why this check against NULL is done > first.
In the expression (!a && !b), if !a equals 0, the compiler must check !b == 0 in order to return TRUE. If !a equals 0, that means the entry is a null pointer, and evaluation of !b is a dereference of a null pointer.