https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97843

--- Comment #2 from Alex <alex at sunopti dot com> ---
I agree that the order of evaluation of operands is undefined and writing code
that depends on that order would not be reliable. In this case it's the
execution of the assign expression happening before all the operands have been
evaluated that is the problem.

The arithmetic equivalent would be for:
X += 4/2
To be produce:
Immediate load Register with 4
Add register with 4 in it to x
Divide register with 4 in it by 2
Resulting in x being increased by 4 instead of 2

10.2.3 Binary expressions EXCEPT for AssignExpression are left to right

10.2.7 says operand order is undefined

Nowhere does the spec say that the assignment operator has to happen after
operand evaluation. I think this is a hole in the spec.

Reply via email to