In this answer , bdonlan states that the code is similar to the following:
int t; volatile int a, b; t = x; a = t; b = t;
can be converted by the compiler to:
a = x; b = x;
My question is: is this allowed if x is an atomic variable with relaxed loads, as in the following?
atomic<int> x; int t; volatile int a, b; t = x.load(std::memory_order_relaxed); a = t; b = t; assert(a == b);
As the title says, are C ++ 11 compilers allowed to introduce additional loads of atomic variables? How about extra stores?
source share