Mixing bitwise and relational operators in the same full expression can be a sign of a logic error in the expression where a logical operator is usually the intended operator. Do not use the bitwise AND (&), bitwise OR (|), or bitwise XOR (^) operators with an operand of type _Bool, or the result of a relational-expression or equality-expression. If the bitwise operator is intended, it should be indicated with use of a parenthesized expression.
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
|---|---|---|---|---|---|
EXP46-C | Low | Likely | Low | P9 | L2 |
Automated Detection
Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| CodeSonar |
| LANG.TYPE.IOT | Inappropriate operand type | ||||||
| CONSTANT_EXPRESSION_RESULT | Can detect the specific instance where bitwise operator is used in place of logical operator, or vice versa. The behavior might be desirable in some situations, so further verification is necessary | |||||||
| Klocwork |
| MISRA.LOGIC.OPERATOR.NOT_BOOL | |||||||
| LDRA tool suite |
| 136 S | Fully Implemented | ||||||
| Parasoft C/C++test | 9.5 | MISRA2004-12_6_{a,b} | Fully implemented | ||||||
| PRQA QA-C |
| 3344,4502 | |||||||
| Cppcheck |
| cert.py | Detected by the addon cert.py |
...