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

SR:  6.3#1Checked automatically with code checker

Synopsis:Values shall not be implicitly converted to a narrower type.
Severity Level:1

Implicit conversions often escape inspections and have led to some extremely expensive failures, c.f. for example, (Hatton, 1994).


short s;
int i;
float fl;
double db;
s = i; /* potential for information loss */
fl = db; /* potential for information loss */
In some cases this highlights a previously unknown problem but in the majority of cases the assignment is intended as the programmer knows that the value is within the range of the smaller type. However, any implicit action is forbidden in favour of an explicit action which indicates clearly that the author intended this situation.