![]() |
![]() |
2900 | ![]() |
||||
![]() | |||||||
| Conversion to unsigned | |||||||
The value of a non-negative integer constant expression is being implicitly converted 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 = 255; /* OK */
unsigned char ucb = 256; /* 2900 */
unsigned short usa = 65535; /* OK */
unsigned short usb = 65536; /* 2900 */
MISRA-C:2004 Rules applicable to message 2900:
| Rule 10.1 (Required) | The value of an expression of integer type shall not be implicitly converted to a different underlying type if: a) it is not a conversion to a wider integer type of the same signedness, or b) the expression is complex, or c) the expression is not constant and is a function argument, or d) the expression is not constant and is a return expression |
See also:
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |