5.5 Multiplicative operators

5.5.1 Ensure that the right hand operand of the division or remainder operators is demonstrably non-zero

The result of integer division or remainder operation is undefined if the right hand operand is zero. Therefore, appropriate safeguards should be coded explicitly (or instrumented by a tool) to ensure that division by zero does not occur.

#include <cstdint>      
#include <cassert>
int32_t doDivide(int32_t number, int32_t divisor)
assert (0 != divisor);
return number / divisor;


  • HIC++ v3.3 – 10.17

Click here for references