![]() |
![]() |
2831 | ![]() |
||||
![]() | |||||||
| Overflow and wraparound | |||||||
A definite anomaly has been detected. Examination of the context indicates that this expression will always result in division by zero. In the example below, n is zero throughout the code contained in the "if" block and the result of the division operation will always be undefined.
/*PRQA S 587,2017,2983,2986,3103,3199,3203,3227,3408 ++*/
void foo(int x, int n)
{
int r;
if (n == 0)
{
r = x / n; /* 2831 */
}
}
MISRA-C:2004 Rules applicable to message 2831:
| Rule 21.1 (Required) | Minimisation of run-time failures shall be ensured by the use of at least one of (a) static analysis tools/techniques; (b) dynamic analysis tools/techniques; (c) explicit coding of checks to handle run-time faults |
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 |