V3004. The 'then' statement is equivalent to the 'else' statement.


The analyzer has detected a suspicious code fragment with an 'if' statement whose both true- and false-statements are absolutely identical. It is often a sign of an error. For example:

if (condition)
  result = FirstFunc(val);
else
  result = FirstFunc(val);

Regardless of the variable's value, the same actions will be performed. This code is obviously incorrect and should have looked something like this:

if (condition)
  result = FirstFunc(val);
else
  result = SecondFunc(val);

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

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


Bugs Found

Checked Projects
364
Collected Errors
13 504