Warning C6288

Incorrect operator: mutual inclusion over && is always zero. Did you intend to use || instead?

Remarks

This warning indicates that in a test expression, a variable is being tested against two different constants. The result depends on both conditions being true, which is impossible. The code in these cases indicates that the programmer's intent isn't captured correctly. It's important to examine the code and correct the problem. Otherwise, your code won't behave the way you expected it to.

This problem is often caused by using &&; in place of ||, but can also be caused by using == where != was intended.

Code analysis name: MUTUALINCLUSIONOVERANDISFALSE

Example

The following code generates this warning:

void f(int x)
{
  if ((x == 1) && (x == 2)) // warning
  {
    // code ...
  }
}

To correct this warning, use the following code:

void f(int x)
{
     if ((x == 1) || (x == 2))
     {
          // logic
     }

    /* or */
    if ((x != 1) && (x != 2))
    {
        // code ...
    }
}

The analysis tool doesn't warn if the expression has side effects.