The right hand operand of a logical && or || operator shall not contain side effects
The right hand operand of a logical && or || operator shall not contain side effects.
When evaluated, an expression with side effect modifies at least one of the
variables in the expression. For instance, n++ is an expression
with side effect.
The right-hand operand of a:
Logical && operator is evaluated only if
the left-hand operand evaluates to true.
Logical || operator is evaluated only if the
left-hand operand evaluates to false.
In other cases, the right-hand operands are not evaluated, so side effects of the expression do not take place. If your program relies on the side effects, you might see unexpected results in those cases.
The checker flags logical && or ||
operators whose right-hand operands are expressions with side effects.
The checker does not consider volatile accesses and function calls as potential side effects.
If you expect a rule violation but do not see it, refer to the documentation for Polyspace® Bug Finder™ or Polyspace Bug Finder Server™.
| Group: Expressions |
| Category: Required |