Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
warning C6287: redundant code: the left and right sub-expressions are identical
This warning indicates that a redundant element was detected in an expression.
It is difficult to judge the severity of this problem without examining the code. A duplicate test on its own is harmless, but the consequences of deleting the second test can be severe. The code should be inspected to ensure that a test was not omitted.
Example
The following code generates this warning:
void f(int x)
{
  if ((x == 1) && (x == 1)) 
  {
    //logic 
  }
  if ((x != 1) || (x != 1))
  {
    //logic
  }
}
The following code shows various methods to correct this warning:
void f(int x, int y)
{
  /* Remove the redundant sub-expression: */
  if (x == 1) 
  {
     // logic 
  }
  if (x != 1) 
  {
    // logic
  }
  /* or test the missing variable: */
  if ((x == 1) && (y == 1))
  {
     // logic
  }
  if ((x != 1) || (y != 1))
  {
     // logic
  }
}