Originally Posted by
CornedBee
Using volatile on simple things, like local variables, is extremely useless. You can use volatile for global variables of type sigatomic_t if you want to react to signals. (Standard C and C++ acknowledge the existence of POSIX-like signals, even though they don't provide a way to fire them, or give any information about when one might be fired.)
You would also probably use volatile for pointers to memory-mapped I/O address ranges. At any time, there might be an interrupt and the device could change the contents of this area. This is stuff that comes from the system-level programming part of C++ and is not really useful in application-level programming.
Actually, the only time I've used volatile was when I wanted to force the compiler away from some optimizations, e.g. to observe the effect of some code and prevent the compiler from just optimizing it away.