I’m pretty much positive about this, but just to be on the safe side:
Does the C standard guarantee that AND chains (A && B && …) will be evaluated left to right, and that evaluation will stop as soon as there’s a 0?
Same question for OR. (As soon as there’s a 1)
Can I count on this for other C-style languages?
Is this code safe:
if (somePtr!=NULL && somePtr->someMember==123)
{
...
}
Yes, it is guaranteed for C, C++ and C#. The same goes for Delphi with “short curcuit evaluation” enabled.
This is behaviour numerous lines of code rely on to this moment.