You are confusing precedence with order of execution.
Example:
a[b] += b += c * d + e * f * g
Precedence rules state that *
comes before +
comes before +=
. Associativity rules (which are part of precedence rules) state that *
is left-associative and +=
is right-associative.
Precedence/associativity rules basically define the application of implicit parenthesis, converting the above expression into:
a[b] += ( b += ( (c * d) + ((e * f) * g) ) )
However, this expression is still evaluated left-to-right.
This means that the index value of b
in the expression a[b]
will use the value of b
from before the b += ...
is executed.
For a more complicated example, mixing ++
and +=
operators, see the question Incrementor logic
, and the detailed answer of how it works.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…