Divide by zero

An expression may divide by zero.

ID

Observation

Description

1

Divide by zero

This shows where the division occurred

Example

          
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);
    }
}
        

Copyright © 2010, Intel Corporation. All rights reserved.