V609. Divide 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);
}

According to Common Weakness Enumeration, potential errors found by using this diagnostic are classified as CWE-369.

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


Bugs Found

Checked Projects
410
Collected Errors
14 111
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →
Accept