That's a great link! Thanks. Interestingly, Linus appears
to have come to the same conclusion about volatile I did:
"But the fact is, that when you
add "volatile" to
the register, it really tells gcc "Be afraid. Be very
afraid. This user
expects some random behaviour that is not actually covered
by any
standard, so just don't ever use this variable for any optimizations,
even
if they are obviously correct. That way he can't complain".
-Linus
(Apology: This message is HTML so a massive link
might still be clickable.)
Go read a Linux Torvalds rant about SMP-safety,
volatile, and "barrier()" (which is the Linux kernel's equivalent of
"sequence"). And much of the thread is interesting, so I'm linking the
whole thing (with this massive link - sorry).
Boiled down, Torvalds believes that "volatile" as
a storage class modifier is always wrong; if "volatile" semantics (whatever
they are) are needed, then apply them at the moment of access (as with a
cast).