TITLE: volatile keyword PROBLEM: Srinivas Vobilisetti (srv@cs.wayne.edu) I referred to various books on C++ including The C++ Programming Language -Bjarne Stroustrup, C++ Primer -Stanley Lipmann, etc. Nowhere i could find exact meaning of the specifier volatile. Thanks in advance for your help. I would appreciate the reply at my email address srv@cs.wayne.edu RESPONSE: kanze@gabi-soft.fr (J. Kanze), 3 Jan 96 According to the ARM, volatile has no portable meaning; the precise meaning is implementation defined. In fact, there are a few odd guarantees in the standard: in particular, reads and writes of a volatile are considered part of the observable behavior of a program. There is also a statement to the effect that the value of a volatile object may change in ways unknown to the compiler. What this means in practice is that the compiler should turn off optimization of volatile variables; the program should do exactly what you wrote, no more, no less. Note that there is no such guarantee with regards to other variables; the only guarantee is that the observable behavior be "as if" the program does what you wrote. Volatile variables are normally used precisely where things are going on "outside of the program". The classical example is a (memory-mapped) real time clock; if the variable were not declared volatile, a good compiler might detect that it was never written, and save the first value read somewhere in a register. Declared volatile, the compiler must read it every time you write an expression which accesses it. What this means exactly *IS* somewhat implementation dependant. When using volatile objects, you should generally eschew complex expressions, particularly those which access the object twice in the same expression, and read the documentation for your implementation very carefully, as to how volatile is interpreted exactly.