Is there always the same execution sequence for various conditions in a If Statement in C++ for all compilers?

Viewed 45

Lets assume a simple If Statement with two conditions A and B:

If ( condA && condB) 

Is the Sequenz for all compilers the Same?

  1. condition A
  2. condition B

And is the execution of condition B therefore optional, in case condition A is already false?

1 Answers

Yes. Not evaluating condition B if A is false is called short circuit logic, and this behavior is guaranteed by the language specification.

Related