...
Modulo behavior resulting from left-shifting an unsigned integer type is permitted by this standardexception INT30-EX3 to INT30-C. Ensure that unsigned integer operations do not wrap.
The UWIDTH()
macro provides the correct width for an unsigned integer type and is defined in
...
...
Use correct integer precisions.
Noncompliant Code Example (Right Shift)
...
The UWIDTH()
macro provides the correct width for an unsigned integer type and is defined in INT19INT35-C. Correctly compute integer widths; see that rule for more informationUse correct integer precisions.
Implementation Details
GCC has no options to handle shifts by negative amounts or by amounts outside the width of the type predictably or to trap on them; they are always treated as undefined. Processors may reduce the shift amount modulo the width of the type. For example, 32-bit shifts are implemented using the following instructions on IAx86-32:
Code Block |
---|
sa[rl]l %cl, %eax |
...
...