Static Analysis Problem Type Reference
An expression may divide by zero.
|
ID |
Code Location |
Description |
|---|---|---|
|
1 |
Divide by zero |
This shows where the division occurred |
extern int b, x, y, z;
void f()
{
if (b) {
x = 2;
y = 1;
} else {
x = 4;
y = 3;
}
// Following statement looks like it could possibly divide by zero
// because x can be 2 and y can be 3. In fact this combination
// of values is impossible so this is a false positive.
z /= (x - y + 1);
// This is a real coding error
if (b == 0) {
z /= (x + y - 7);
}
}