Many C (sub-)expression have a value and a side effect.
The value of b++
is the value of b
before evaluating the expression; its side effect is to increase the value in b
by one.
So, the expression return b++;
returns the previous value of b
and updates b
.
When b
is static the update stays around for the next function call;
when b
is a plain old local variable, the update is lost (a smart compiler will even not emit code to update the object).