Subj : Re: Memory Barriers, Compiler Optimizations, etc. To : comp.programming.threads From : Alexander Terekhov Date : Mon Feb 07 2005 01:46 pm Joseph Seigh wrote: > > On Mon, 07 Feb 2005 11:17:07 +0100, Alexander Terekhov wrote: > > > > > Yes. Note that I said "volatile abuse". Simply put, when you write > > something like > > > > volatile int i = 1; > > > > int main() { > > return --i; > > } > > > > you better be prepared that smart compiler can tranform it to > > > > int main() { > > } > > > > The variable i doesn't have an external attribute. It can't be > seen anyway. And since the C/C++ standards don't concern themselves with threads, use of "internal" volatiles by multiple threads doesn't constitute "external attribute" in your terminology. IOW, C/C++ compiler can simply ignore volatile abuse and treat all such variables as nonvolatile. regards, alexander. .