 
                            ...
Performing bitwise operations on signed numbers can lead to buffer overflows and the execution of arbitrary code by an attacker in some cases, unexpected or implementation-defined behavior in others.
| Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level | 
|---|---|---|---|---|---|
| INT13-C | High | Unlikely | Medium | P6 | L2 | 
Automated Detection
| Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Astrée | 
 | bitop-type | Fully checked | ||||||
| CodeSonar | 
 | LANG.TYPE.IOT | Inappropriate operand type | ||||||
| Compass/ROSE | 
| Can detect violations of this rule. In particular, it flags bitwise operations that involved variables not declared with  | |||||||||
| 
 | CC2.INT13 | Fully implemented | |||||||
| Klocwork | 
 | MISRA.BITS.NOT_UNSIGNED MISRA.BITS.NOT_UNSIGNED.PREP | 
| LDRA tool suite | 
 | 50 S | Fully implemented | ||||||
| Parasoft C/C++test | 
 | 
| 
 | 
| 
 | MISRA2008-5_0_21 | Fully implemented | |||||||
| R2016b | Bitwise operation on negative value | Undefined behavior for bitwise operations on negative values | |||||||
| PRQA QA-C | 
 | 4532, 4533, 4534, 4543, 4544 | Fully implemented | ||||||
| RuleChecker | 
 | bitop-type | Fully checked | ||||||
| SonarQube C/C++ Plugin | 
 | 
| Splint | 
 | 
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
| SEI CERT C++ Coding Standard | VOID INT13-CPP. Use bitwise operators only on unsigned operands | 
| ISO/IEC TR 24772:2013 | Bit Representations [STR] Arithmetic Wrap-around Error [FIF] Sign Extension Error [XZI] | 
| MITRE CWE | CWE-682, Incorrect calculation | 
Bibliography
| [Dowd 2006] | Chapter 6, "C Language Issues" | 
| [C99 Rationale 2003] | Subclause 6.5.7, "Bitwise Shift Operators" | 
...
...