...
In this noncompliant code example, a bitwise & operator operator is used with the results of an two equality-expressionexpressions:
| Code Block | 
|---|
|  | 
| if (!(getuid() == 0 & geteuidgetgid() == 0)) { 
  /* ... */ 
} 
 | 
Compliant Solution
...
| Code Block | 
|---|
|  | 
| if (!(getuid() == 0 && geteuidgetgid() == 0)) {
  /* ... */
}
 | 
Risk Assessment
...
| Tool | Version | Checker | Description | 
|---|
| Astrée |  | inappropriate-boolSupported indirectly via MISRA C:2012 Rule 10.1 | bitwise-operator-with-boolean-like-operand | Fully checked | 
| Axivion Bauhaus Suite | | Include Page | 
|---|
 | |  | Axivion Bauhaus Suite_V | 
|---|
 |  | Axivion Bauhaus Suite_V | 
|---|
 | 
 | CertC-EXP46 | 
 | 
| CodeSonar |  | LANG.TYPE.IOT | Inappropriate operand type | 
| Coverity |  | CONSTANT_EXPRESSION_RESULT | Partially implemented | 
| Cppcheck |  | bitwiseOnBoolean | 
 | 
| Cppcheck Premium |  | cert.py |  | bitwiseOnBooleanDetected by the addon cert.py | 
 | 
| Helix QAC |  | C3344, C4502 C++3709 | 
 | 
| Klocwork |  | MISRA.LOGIC.OPERATOR.NOT_BOOL | 
 | 
| LDRA tool suite |  | 136 S | Fully Implemented | 
| Parasoft C/C++test |  | CERT_C-EXP46-b | Expressions that are effectively Boolean should not be used as operands to operators other than (&&, ||, !, =, ==, !=, ?:) | 
| PC-lint Plus | | Include Page | 
|---|
 | |  | PC-lint Plus_V | 
|---|
 |  | PC-lint Plus_V | 
|---|
 | 
 | 514 | Fully supported | 
| Polyspace Bug Finder | | Include Page | 
|---|
 | |  | Polyspace Bug Finder_V | 
|---|
 |  | Polyspace Bug Finder_V | 
|---|
 | 
 | CERT C: Rule EXP46-C | PRQA QAChecks for bitwise operations on boolean operands (rule fully covered) | 
| PVS-C | Studio | PRQA QA | C | v | PRQA QA | C | v | 3344 | V564,4502 | V1015 
 | 
 | 
| RuleCheckerPRQA QA-C++ | | Include Page | 
|---|
 | |  | cplusplus:PRQA QA-C++RuleChecker_Vcplusplus:PRQA QA-C++ | 
|---|
 |  | RuleChecker_V | 
|---|
 | 
 | 3709 | PVS-Studio | | Include Page | 
|---|
PVS-Studio_V | PVS-Studio_V | bitwise-operator-with-boolean-like-operand | Fully checked | 
| Security Reviewer - Static Reviewer | | Include Page | 
|---|
 | |  | Security Reviewer - Static Reviewer_V | 
|---|
 |  | Security Reviewer - Static Reviewer_V | 
|---|
 | 
 | C73 | Fully implemented | V564, V1015 
 | RuleChecker | | Include Page | 
|---|
RuleChecker_V | RuleChecker_V | inappropriate-bool | Supported indirectly via MISRA C:2012 Rule 10.1 | 
Related Guidelines
Key here (explains table format and definitions)
...