Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC++atomics and memory orderingSingle-choice MCQ

In the classic store-buffer (Dekker-style) litmus test below, all atomics start at 0. With which single memory ordering on the stores AND loads is the outcome r1==0 && r2==0 forbidden by the C++ standard?

std::atomic<int> x{0}, y{0}; int r1, r2; // Thread 1 x.store(1, ORDER); r1 = y.load(ORDER); // Thread 2 y.store(1, ORDER); r2 = x.load(ORDER);