In computer programming, the volatile keyword indicates that a value may change between different accesses, even if it does not appear to be modified. This prevents an optimizing compiler from optimizing away subsequent reads or writes and thus incorrectly reusing a stale value or omitting writes. Volatile values primarily arise in hardware access where reading from or writing to memory is used to communicate with peripheral devices.