Synopsis: | The left operand of a shift operator must not be signed. |
Language: | C |
Severity Level: | 10 |
Category: | EXPRESSIONS |
Description: |
A signed left operand of a right shift will produce an arithmetic shift on some platforms
and a logical shift on others.
Example: int j; unsigned int x; unsigned int u; ... x = j >> 8; /* WRONG */int j; unsigned int x; unsigned int u; ... x = u >> 8; /* RIGHT */ |