If the denominator to a division or modulo operation is zero, the behavior of the application is undefined.
Operator /
is used for division and %
for modulo operation. Division and modulo operations are susceptible to
divide-by-zero (and signed integer overflow) errors.
int foo(int a, int b) {
if (b == 0) {
a = 1;
}
return a / b; // Noncompliant: potential divide-by-zero error
}