![]() |
![]() |
2912 | ![]() |
||||
![]() | |||||||
| Overflow and wraparound | |||||||
An arithmetic operation is being performed in an unsigned type. Examination of the context indicates that the result will sometimes be too large to be representable in this type and so wraparound will occur - the result will be truncated using modulo arithmetic. Perhaps this is intended ? For example:
/*PRQA S 1278,2017,2982,2983,2984,2986,3120,3198,3199,3203,3227,3382,3408 ++*/
/*******************************/
/* OPTIONS: -s int=16 */
/*******************************/
void foo(unsigned int un)
{
if (un > 10000U)
{
}
un = un * 7U; /* 2912 */
}
No MISRA C:2012 Rules applicable to message 2912
See also:
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |