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

Rule:  6.5.4.aChecked automatically with code checker

Synopsis:Casting shall only be used to denote required casting.
Language:C
Severity Level:8
Category:Expressions


Description:

Justification

Casting requires special attention from the reader of the source code and should not be used when not needed. Casting is required in unsafe (loss of sign, loss of precision) implicit conversions.

Example

const int m = 5;

long p = (long) m; /* WRONG, conversion from int to long is safe */

int* q = (int*) &m; /* RIGHT, unsafe conversion to non-const */