Operator precedence and associativity does not tell you what happens before and what happens after. Operator precedence/associativity has nothing to do with it. In C language temporal relationships like "before" or "after" are defined by so called sequence points and only by sequence points (and that's a totally separate story).
Operator precedence/associativity simply tells you which operands belong to which operators. For example, the expression a = b++
can be formally interpreted as (a = b)++
and as a = (b++)
. Operator precedence/associativity is this case simply tells you that the latter interpretation is correct and the former is incorrect (i.e. ++
applies to b
and not to the result of a = b
).
That, once again, does not mean that b
should be incremented first. Operator precedence/associativity, once again, has noting to do with what happens "first" and what happens "next". It simply tells you that the result of b++
expression is assigned to a
. By definition, the result of b++
(postfix increment) is the original value of b
. This is why a
will get the original value of b
, which is 1. When the variable b
will get incremented is completely irrelevant, as long as a
gets assigned b
's original value. The compiler is allowed to evaluate this expression in any order and increment b
at any time: anything goes, as long as a
somehow gets the original value of b
(and nobody really cares how that "somehow" works internally).
For example, the compiler can evaluate a = b++
as the following sequence of elementary operations
(1) a := b
(2) b := b + 1
or it can evaluate it as follows
(1) b := b + 1
(2) a = b - 1
Note that in the first case b
is actually incremented at the end, while in the second case b
is incremented first. But in both cases a
gets the same correct value - the original value of b
, which is what it should get.
But I have to reiterate that the above two examples are here just for illustrative purposes. In reality, expressions like a = ++b
and a = b++
have no sequence points inside, which means that from your point of view everything in these expressions happens simultaneously. There's no "before", "after", "first", "next" or "last". Such expressions are "atomic" in a sense that they cannot be meaningfully decomposed into a sequence of smaller steps.