TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
TIOBE - C Coding Standard
Search

SR:  7.8#2Checked automatically with code checker

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 */