We know that logical-AND operator (&&
) guarantees left-to-right evaluation.
But I am wondering if the compiler optimizer can ever reorder the me
The system can evaluate b->foo
until such time as it hits something that exceeds its ability to execute speculatively. Most modern systems can handle a speculative fault and ignore the fault if it turns out that the results of the operation are never used.
So it's purely up to the capabilities of the compiler, CPU, and other system components. So long as it can ensure there are no visible consequences to conforming code, it can execute (almost) anything it wants (almost) any time it wants.