[previous] 2830 [next] Constant: Division by zero.
Overflow and wraparound

A division (/) or remainder (%) operation has been encountered in which the second operand is a constant expression of value zero. The result will be undefined.

For example:


/*PRQA S 586,2017,2983,2986,3103,3199,3203,3227,3408 ++*/

#define RED  45
#define GRN  45

extern void foo(int n)
{
   int r;

   r = n / (RED - GRN);                     /* 2830 */
}


MISRA-C:2004 Rules applicable to message 2830:

Rule  1.2  (Required) No reliance shall be placed on undefined or unspecified behaviour.


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