> We know that the C++ keyword volatile is used to prevent a value from being optimized in a way that would allow the compiler to keep it in a processor register rather than fetching it from its original memory location each time.
Actually, we don't know that. The meaning of volatile is rather subtle