This is a very basic question, but many intersting concepts emerge out of it.
Answer is "Behaviour is Undefined".A compiler may do anything it likes when faced with undefined behavior (and, within limits, with implementation-defined and unspecified behavior), including doing what you expect.
Briefly: implementation-defined means that an implementation must choose some behavior and document it.
Unspecified means that an implementation should choose some behavior, but need not document it.
Undefined means that absolutely anything might happen.
In no case does the Standard impose requirements; in the first two cases it occasionally suggests (and may require a choice from among) a small set of likely behaviors.
The concept of sequence point can be used to base a discussion on
A sequence point is a point in time (at the end of the
evaluation of a full expression, or at the ||, &&, ?:, or comma
operators, or just before a function call) at which the dust
has settled and all side effects are guaranteed to be complete.
The ANSI/ISO C Standard states that
"
Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be accessed only to determine the value to be stored."
The second sentence can be difficult to understand.
It says
that if an object is written to within a full expression, any
and all accesses to it within the same expression must be for
the purposes of computing the value to be written.
This rule
effectively constrains legal expressions to those in which the
accesses demonstrably precede the modification(as above).