V3011. Two opposite conditions were encountered. The second condition is always false.

The analyzer has detected a potential logical error: two conditional statements executed in sequence contain mutually exclusive conditions.

Examples of such conditions:

  • "A == B" and "A != B";
  • "A > B" and "A <= B";
  • "A < B" and "B < A";
  • and so on.

This error can occur as a result of a typo or bad refactoring.

Consider the following example of incorrect code:

if (x == y)
  if (y != x)
    DoSomething(x, y);

In this fragment, the 'DoSomething' method will never be called because the second condition will always be false when the first one is true. One of the variables used in the comparison is probably wrong. In the second condition, for example, variable 'z' should have been used instead of 'x':

if (x == y)
  if (y != z)
    DoSomething(x, y);

This diagnostic is classified as:

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

Bugs Found

Checked Projects
Collected Errors
14 526
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 →