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.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for