# V609. Possible division or mod by zero.

The analyzer has detected a situation when division by zero may occur.

Consider this sample:

    for (int i = -10; i != 10; ++i)
    {
      Foo(X / i);
    }

While executing the loop, the 'i' variable will acquire a value equal to 0. At this moment, an operation of division by zero will occur. To fix it we need to specifically handle the case when the 'i' iterator equals zero.

This is the correct code:

    for (int i = -10; i != 10; ++i)
    {
      if (i != 0)
        Foo(X / i);
    }

This diagnostic is classified as:

CWE-369 CERT-INT33-C

You can look at examples of errors detected by the V609 diagnostic.