[previous] 2905 [next] Constant: Positive integer value truncated by cast to a smaller unsigned type.
Conversion to unsigned

The value of a non-negative integer constant expression is being cast to an unsigned type. The value of the expression is larger than the maximum value which can be represented in this type and so truncation will occur using modulo arithmetic.

For example:


/*PRQA S 1255,2017,3120,3211,3306,3408,3606 ++*/


unsigned char  uca = (unsigned char)255;                 /*      */
unsigned char  ucb = (unsigned char)256;                 /* 2905 */
unsigned short usa = (unsigned short)65535;              /*      */
unsigned short usb = (unsigned short)65536;              /* 2905 */

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents