MISRA Discussion Forums

Full Version: Rule 12.6, effectively Boolean expressions in assignment?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The second sentence in Rule 12.6 says \"Expressions that are effectively Boolean should not be used as operands to operators other than (&&, || and !).\"

This makes sense for most operators, but what about the simple assignment operator?

bool a;

a = (b == c); /* is this allowed? */

Perhaps a disclaimer \"other than assignment\" could be added?
An effectively boolean expression can be the operand of the assignment operator or any operand of the ternary operator.

a = (b == c);  
a = b > 5;
c = a || b;

These are allowed

Full clarification will be in Technical Clarification 1.