(Apology: This message is HTML so a massive link might still be clickable.)
 
"Walter" <walter@digitalmars.com> wrote in message news:a7qrji$1bnv$1@digitaldaemon.com...
>
> "Stephen Fuld" <
s.fuld.pleaseremove@att.net> wrote in message
>
news:a7gom0$96n$1@digitaldaemon.com...
> >> Oh, that's intuitive!  :-(  Add an extra empty function call in order to
> > prevent the compiler from doing some undesirable optimization.  Uccccch!
> > There has got to be a better way to address the problem than this.  I'm
> not
> > wedded to the "volatile" syntax and certainly not wedded to how C does
> > things.  I was just pointing out, for those who have never done embedded
> > programming, a major reason for that syntax.  If you can come up with a
> > better solution (I guess I don't count the ones you have proposed so far
> to
> > be better.) than I am all for it.  You have showed such immagination in
> > solving other C/C++ deficiencies that I have reason to hope you can solve
> > this one elegantly.
>
> I did have a thought. How about a keyword "sequence", as in:
>
>     sequence;        // no caching across this keyword
>     x = *p;            // *p is always reloaded
>
> and:
>     x = *p;
>     sequence;        // *p is not cached
>
>
 
This reminded me of something, so I did a quick Google search.
 
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).
 
http://groups.google.com/groups?hl=en&threadm=linux.kernel.Pine.LNX.4.33.0107231546430.7916-100000%40penguin.transmeta.com&rnum=5&prev=/groups%3Fq%3Dtorvalds%2Btransmeta%2Bbarrier%26hl%3Den
 
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).
 
--
Richard Krehbiel, Arlington, VA, USA
rich@kastle.com (work) or krehbiel3@comcast.net  (personal)