arnold said:
ok, see. so logically, within one expression, that would mean
use value of i, in the next expression containing i use i+1
No. For _correct_ code, it could be expressed somewhat inaccurately as
something like
use value of i, starting with the next _full_ expression containing i
use i+1
However...
let me check if I understand, an expression of the form
(((i_1++ - b) / 3) + i_2++) + c-i_3)
would then mean
i_1 expression: use value of i_1,
i_2 expression: use value of i_1+1,
i_3 expression: use value of i_1+2
i_1, i_2 and i_3 are not full expressions, they are sub-expressions of
the whole line.
Actually, "full expression" is misleading. The real sticking point is
"between sequence points". The end of a statement is a sequence point,
but so are some select operators such as the logical (&&, ||) and comma
operators, and the actual call of a function, _after_ all its operands
have been determined, and some others. The * operator, however, is not,
and neither is any of the operators in your line above.
The real meaning of i++ is
evaluate to the value of i, and as a side effect, increment i
and that of ++i is
evaluate to the value of i plus one, and as a side effect, increment i
In neither of these cases is there any guarantee about the order in
which the the evaluation and the side effect are performed; and all side
effects _may_ be done just after the previous sequence point (statement
start, logical operator) and they _may_ be done just before the next
sequence point (end of the statement, function call), or they may be
done as a left-to-right reading of the code would indicate, or they may
even be shoved off to a parallel processor and done at the same time as
the main value of the expression is calculated. Or worse.
But since the OP's expression uses macro it al changes and leads to
undefined behaviour.
The macro _as such_ has nothing to do with it. The problem is that
_this_ macro, applied as it is, expands to
i++ * i++
and _that_ expression causes the undefined behaviour. It would do so if
it were entered straight into the code just as much as when it comes
from a macro.
Richard