As this is a C expression it should follow some cascading evaluation steps to find out result.
your expressions are
--++foo;
ok lets evaluate this
first step:-
++foo;
must be evaluated to proceed
it is some how pre increment so foo become foo+1 .
then assignment happen
that is this evaluate to foo=foo+1;
and value of foo return for assignment to a variable(if nothing present then ignored).
so now our expression is like below
--(++foo); evaluated to
--(a constant value);//result of foo+1
again the statement evaluated like
a constant value=constant_valu+1;//right part is ok but left part is not a variable
as left side of assignment operator is not a variablle and raise an error.
so now no valid operand for -- /decrement operator So lvalue required error
--foo++
is a "valid statement" is easily achieved by feeding it to the compiler. No error says "valid". – Aristotelianism--++foo;
? What compiler is that ? – Stepmother(++i * 0) + ++i
is invalid. Although it might compile to who-knows-what. – Clinkscales