MISRAC++2008-4-5-1
In this section:
Synopsis
(Required) Expressions with type bool shall not be used as operands to built-in operators other than the assignment operator =, the logical operators &&, ||, !, the equality operators == and !=, the unary & operator, and the conditional operator.
Enabled by default
Yes
Severity/Certainty
Low/Low

Full description
Arithmetic operators are used on boolean operands. This check is identical to MISRAC2004-12.6_b.
Coding standards
- MISRA C:2004 12.6
(Advisory) The operands of logical operators (&&, ||, and !) should be effectively boolean. Expressions that are effectively boolean should not be used as operands to operators other than (&&, ||, !, =, ==, !=, and ?:).
Code examples
The following code example fails the check and will give a warning:
void func(bool b)
{
bool x;
bool y;
y = x % b;
}
The following code example passes the check and will not give a warning about this issue:
typedef char boolean_t; /* Compliant: Boolean-by-enforcement */
void example(void)
{
boolean_t d;
boolean_t c = 1;
boolean_t b = 0;
boolean_t a = 1;
d = ( c && a ) && b;
}
void func()
{
bool x;
bool y;
y = x && y;
}