c = a++++b;
regarded as:
c = ((a++)++)b;
which is wrong as you try to increase non-lvalue.
and
c = a++*+b;
regarded as:
c = (a++)*(+b);
The reason for this behavior is: the lexical analyzer of the C language is greedy .
In case 1: after the token 'a' (identifier), lexer sees + followed by the other +, so it consumes both (as an increment operator) as part of the same token. It does not make the third + part of the same token as +++ is not a valid token. Similarly, it groups the following two + into + tokens, making it the same as:
c = ((a++)++)b;
which is wrong, since ++ does not return an lvalue, so you cannot apply ++ to it. Something like saying 5 ++;
But in case 2: the first pair ++ will be grouped (as an increment operator). Then only one * will be a token, since you cannot combine it with + as * +, it is not a valid token. Finally, + will be a token (like unary +), effectively making your statement as follows:
c = (a++)*(+b);
You can override this greedy lexer behavior using parentheses or spaces as follows:
c = a++ + +b; c = a++ * +b;
codaddict
source share