...
The typedef name uintN_t designates an unsigned integer type with width N. Consequently, uint32_t denotes an unsigned integer type with a width of exactly 32 bits. Bitmaps should be declared as unsigned see . See guidline INT13-C. Use bitwise operators only on unsigned operands.
...
In this noncompliant code example, both bit manipulation and arithmetic manipulation are performed on the integer x. The result is a (prematurely) optimized statement that assigns 5x + 1 to x for implementations, where integers are represented as two's complement values.
...
Although this code is likely to perform the division correctly, it is not guaranteed to. If x has a signed type and a negative value, the operation is implementation defined and can be implemented as either an arithmetic shift or a logical shift. In the event of a logical shift, if the integer is represented in either one's complement or two's complement form, the most significant bit (which controls the sign for both representations) will be set to zero. This will cause a once negative number to become a possibly very large, positive number. For more details, see guideline INT13-C. Use bitwise operators only on unsigned operands.
...
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
|---|---|---|---|---|---|
INT14-C | medium | unlikely | medium | P4 | L3 |
Automated Detection
Tool | Version | Checker | Description |
|---|---|---|---|
|
...
|
|
|
...
|
|
|
|
...
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Other Languages
Related Guidelines
This rule appears in the C++ Secure Coding Standard as : INT14-CPP. Avoid performing bitwise and arithmetic operations on the same data.
Bibliography
| Wiki Markup |
|---|
\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 6.2.6.2, "Integer types" \[[ISO/IEC PDTR 24772|AA. Bibliography#ISO/IEC PDTR 24772]\] "STR Bit Representations" \[[MISRA 042004|AA. Bibliography#MISRA 04]\] Rules 6.4 and 6.5 \[[Steele 771977|AA. Bibliography#Steele 77]\] |
...