 
                            ...
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 | Supported, but no explicit checker
 | bitwise-operator-with-boolean-like-operand | Fully checked | ||||||||||||||||
| Axivion Bauhaus Suite | 
 | CertC-EXP46 | |||||||||||||||||
| CodeSonar | 
 | LANG.TYPE.IOT | Inappropriate operand type | ||||||||||||||||
| 
 | CONSTANT_EXPRESSION_RESULT | Partially implemented | |||||||||||||||||
| Cppcheck | 
 | cert.py | bitwiseOnBoolean | ||||||||||||||||
| Cppcheck Premium | 
 | bitwiseOnBoolean | |||||||||||||||||
| Helix QAC | 
 | C3344, C4502 C++3709Detected by the addon cert.py | |||||||||||||||||
| Klocwork | 
 | MISRA.LOGIC.OPERATOR.NOT_BOOL | |||||||||||||||||
| LDRA tool suite | 
 | 136 S | Fully Implemented | ||||||||||||||||
| Parasoft C/C++test | 
 | aCERT_C-EXP46- | The operands of logical operators (&&, || and !) should be effectively Booleanb | Expressions that are effectively Boolean should not be used as operands to operators other than (&&, ||, !, =, ==, !=, ?:) | |||||||||||||||
| PC-lint Plus | 
 | 514 | Fully supported | ||||||||||||||||
| Polyspace Bug Finder | MISRA
 | CERT C:2012 Rule 10.1 | Operands shall not be of an inappropriate essential type | PRQA QA-C | |||||||||||||||
| Include Page | PRQA QA-C_v | PRQA QA-C_v | 3344,4502 | PRQA CA-C++ | 4.2 | 3709 | Rule EXP46-C | Checks for bitwise operations on boolean operands (rule fully covered) | |||||||||||
| PVS-Studio | 
 | V564, V1015 | |||||||||||||||||
| RuleChecker | 
 | bitwise-operator-with-boolean-like-operand | Fully checked | ||||||||||||||||
| Security Reviewer - Static Reviewer | 
 | C73 | Fully implemented | PVS-Studio | | Include Page |  | PVS-Studio_V | PVS-Studio_VV564 | 
Related Guidelines
Key here (explains table format and definitions)
...
Intersection( EXP45-C, EXP46-C) = Ø
CWE-480 = Union( EXP46-C, list) where list =
...