Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

C6289

warning C6289: Incorrect operator: mutual exclusion over || is always a non-zero constant. Did you intend to use && instead?

This warning indicates that in a test expression a variable is being tested against two different constants and the result depends on either condition being true. This always evaluates to true.

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

The following code generates this warning:

void f(int x)
{
  if ((x != 1) || (x != 3))
  {
    // code 
  }
}

To correct this warning, use the following code:

void f(int x)
{
  if ((x != 1) && (x != 3))
  {
    // code 
  }
}

/* or */
void f(int x)
{
  if ((x == 1) || (x == 3))
  {
    // code 
  }
}
Show:
© 2015 Microsoft