That's true of course. But the first comment is really more
enlightening. It's undefined *because* a compiler might reasonably
perform the calculation in one of several natural orders. It's not
some unmotivated rule to trap the unwary. Though the standard allows
the proverbial nasal demons, they are merely an artefact of the way
the standard authors decided to handle these cases.
That would justify "unspecified". Undefined behavior is a stronger term.
I seem to recall being told that there have been systems in which naive
instruction scheduling could result in spectacularly weird behavior from
things like the "i = ++i" example, because the generated code could end
up copying registers which had been partially but not completely updated.
(There have been systems in which you could load a 32-bit register 16
bits at a time -- if your scheduler assumed that code didn't have overlapping
side-effects like this, you could end up with something copying a value which
was in the middle of being updated, which could produce very weird results.)
I've seen one of these once, although I no longer remember the details.
I believe it was code to the effect of:
i = ++i % 4;
and produced a sequence something like
1 5 65 513
It was, to put it mildly, pretty weird. (I probably have the details
of the sequence wrong, but it was something of that nature; it was not
particularly obvious.)
-s