AFAIK c++ guarantees that in a expression a-expr && b-expr
b-expr
is not evaluated if a-expr
is false
. (Similar is true for or-expressions)
does that mean that there will be a jump in the generated code that will flush the cpu-pipeline?
Or how can/is this be prevented?
what if the expressions are so simple that stupiditly calculating all the results would be faster than the short-circuit? Can this be detected/exploited by compilers?
Or do the programmer have to seperate all the expressions into single variable assignments and maybe use bitwise instead logic operators to prevent such jumps?
3