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

C6319

warning C6319: use of the comma-operator in a tested expression causes the left argument to be ignored when it has no side-effects

This warning indicates an ignored sub-expression in test context because of the comma-operator (,). The comma operator has left-to-right associativity. The result of the comma-operator is the last expression evaluated. If the left expression to comma-operator has no side effects, the compiler might omit code generation for the expression.

The following code generates this warning:

void f()
{
  int i;
  int x[10];

  // code 
  for ( i = 0; x[i] != 0, x[i] < 42; i++)  // warning
  {
    // code
  }
}

To correct this warning, use the logical AND operator as shown in the following code:

void f()
{
  int i;
  int x[10];

  // code 

  for ( i = 0; (x[i] != 0) && (x[i] < 42); i++) 
  {
    // code
  }
} 
Show:
© 2015 Microsoft