The grammar for the for
iteration-statement in C89 is
for
(
expressionopt;
expressionopt;
expressionopt)
statement
Where expressionopt is either an expression or omitted: e.g. for (;;);
is valid C
. Simply put, {y++; x++;}
is not an expressionopt but rather it's a statement. So it can't be used in the for
loop. Something like x++, y++
is an expression with a value of the previous value of y
so it can be.
In later versions of C, the first expressionopt is enhanced to a clause which permits code like for (int a...
. But this is not valid in C89. But code like for (x = 1, y = 2;
is valid since x = 1, y = 2
is an expression.