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