"The C++ Programming Language" 对 volatile 修饰词的说明:
A volatile specifier is a hint to a compiler that an object may change its value in ways not specified by the language so that aggressive optimizations must be avoided.
有这个关键字的原因是有些编译器会优化变量,认为你没有改变时就会直接取该变量上次临时存储的右值,而不是从变量地址处重新取值。
例如汇编,例如多线程