Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 12.6, effectively Boolean expressions in assignment?
#1
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?

Code:
bool a;

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

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

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

These are allowed

Full clarification will be in Technical Clarification 1.
Posted by and on behalf of the MISRA C Working Group


Forum Jump:


Users browsing this thread: 2 Guest(s)