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

Category: Conversions

Synopsis:Rules about conversions between types


Description:

Several operators convert operand values from one type to another automatically. This subclause specifies the result required from such an implicit conversion, as well as those that result from a cast operation (an explicit conversion).

Coding Rules

NameCheckedSynopsis
6.3.a Checked automatically with code checker Unsafe implicit conversions in expressions, return statements, assignment statements or argument lists shall not be used. Unsafe means: conversions where values are truncated and/or sign can be lost.
6.3.b Checked automatically with code checker Unsafe implicit conversions of literals shall be avoided.
6.3.1.a Checked automatically with code checker Mixed signed/unsigned type arithmetic shall not be used.
6.3.2.1.a Checked automatically with code checker void expressions shall not be used in expressions.
6.3.2.2.a Checked automatically with code checker Pointer to and from integer conversions shall not be used. For instance on 64-bit x86 processors the size of an integer is 32-bits while the pointer is 64-bits. Therefore converting a pointer to an integer will discard part of the address.
6.3.2.2.b Checked automatically with code checker For generic pointers void * shall be used rather than char *.
6.3.2.2.c Checked automatically with code checker Pointers shall not be converted to other pointer types.
6.3.2.2.d Checked automatically with code checker Pointers shall not be added, multiplied nor divided.
6.3.2.2.e Checked automatically with code checker Pointers shall not be subtracted from each other, unless their unqualified type is the same.
6.3.2.3.a Checked automatically with code checker bool shall be used as boolean type.
6.3.2.3.d Checked automatically with code checker Avoid conversions between booleans and non-boolean types