Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC++relaxed memory semanticsSingle-choice MCQ

Under the C++ memory model, the 'out-of-thin-air' (OOTA) problem concerns a cycle where two relaxed loads each justify the other's stored value (e.g., r1 = x.load(relaxed) then y.store(r1, relaxed); symmetrically with y/x). What is the standard's actual position?

std::atomic<int> x{0}, y{0}; // Thread 1 int r1 = x.load(std::memory_order_relaxed); y.store(r1, std::memory_order_relaxed); // Thread 2 int r2 = y.load(std::memory_order_relaxed); x.store(r2, std::memory_order_relaxed); // Could r1 == r2 == 42 appear from thin air?