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

SR:  7.8#3

Synopsis:Left shifts in constant expressions shall not be such as to truncate any bits from the result.
Language:C
Severity Level:3
Category:EXPRESSIONS


Description:
The left shift results in bits 'falling off' the end. Truncation of the constant expression value occurs as soon as 'occupied' bits start being shed. Up until this point the resultant value was representable.

Example:

#if (15u << 30) /* bits fall off end */
An artificial example but it demonstrates the loss of information (if constant expres-sions are represented in 4 bytes).