V517. The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence.

The analyzer detected a possible error in a construct consisting of conditional statements. Consider the sample:

if (a == 1)
else if (a == 2)
else if (a == 1)

In this sample, the 'Foo3()' function will never get control. Most likely, we deal with a logical error and the correct code should look as follows:

if (a == 1)
else if (a == 2)
else if (a == 3)

In practice, such an error might look in the following way:

if (radius < THRESH * 5)
  *yOut = THRESH * 10 / radius;
else if (radius < THRESH * 5)
  *yOut = -3.0f / (THRESH * 5.0f) * (radius - THRESH * 5.0f) + 3.0f;
   *yOut = 0.0f;

It is difficult to say how a correct comparison condition must look, but the error in this code is evident.

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

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

Bugs Found

Checked Projects
Collected Errors
13 303