Should std::atomic be volatile?
Is the compiler free to cache the value of the atomic variable and unroll the loop? The compiler cannot cache the value of an atomic variable. However, since you are using std::memory_order_relaxed, that means the compiler is free to reorder loads and stores from/to this atomic variable with regards to other loads and stores. Also … Read more