Aug. 1, 2011
11:45 p.m.
C absolutely guarantees that the second will NEVER be evaluated before the first. Otherwise, things like this:
if ( ptr && ptr->field )
could fail if ptr was NULL.
In your example yes. But is there a problem if the two conditions are independent ? for eg.. foo() { .... a = 0; b = my_complex_function_call(); if (b && a) { /* Do some non-trivial stuff */ } else { printf("I'm an intelligent compiler\n"); } ..... } Does C guarantee that even in this case it won't be reordered and not optimized ? -- Thanks - Manish