Nothing Orders Memory
Both atomics start at 0.
std::atomic<int> x{0}, y{0};
// thread A
x.store(1, std::memory_order_relaxed);
y.store(1, std::memory_order_relaxed);
// thread B
int a = y.load(std::memory_order_relaxed); // reads 1
int b = x.load(std::memory_order_relaxed); // reads ?
Thread B observes a == 1. Is b == 0 a legal outcome under the C++ memory model?
Sign in to answer questions and track your progress
Sign In