"Ron Natalie" <ron(a)ronnatalie.com> wrote:
|There's a trademark between allowing the compiler to reorder things \
|and having a defined order of operations.
|Steps like that are well-defined in Java for instance. C lets the \
|compiler do what it sees fit.
|
|Note that it's not necessarily any better in assembler. There are \
|RISC architectures where load-followed-by-store and vice versa may \
|not always be valid if done in quick succession. Requiring the compiler \
|to insert sequence points typically wastes a lot of cycles. Assembler \
|programmers tend to think about what they are doing, the C compiler \
|tries to do some of this on its own and its not clairvoyant.
I have just read again Clive Feather's ISO/IEC JTC1/SC22/WG14 N925
draft on sequence points, and i seem to be wrong about especially
the shown exampl,e and Random knew that earlier. I first read
that document in the context of aliasing issues a few years back,
when i saw some BSD changesets fly by, and i remember a thread on
a FreeBSD list, too, where objects backing pointers could no
longer be accessed directly, but first need to be copied over to
some -- then newly introduced -- local scope storage before being
used, because of new aliasing rules of the C language. It seems
i hyperventilated in the sequence point document back then.
--steffen