Warning C6319
Use of the comma-operator in a tested expression causes the left argument to be ignored when it has no side-effects
Remarks
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.
Code analysis name: IGNOREDBYCOMMA
Example
The following code generates this warning:
void f()
{
int i;
int x[10];
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];
for ( i = 0; (x[i] != 0) && (x[i] < 42); i++)
{
// code
}
}