Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC++the C++ memory modelSingle-choice MCQ

A flag is published with store(release) and consumed with load(acquire). A separate, ordinary non-atomic write happens-before the release store on the producer. After the consumer sees the flag via the acquire load, is it guaranteed to observe that non-atomic write, and what mechanism provides the guarantee?

int data = 0; std::atomic<bool> ready{false}; // producer: data = 7; ready.store(true, std::memory_order_release); // consumer: while (!ready.load(std::memory_order_acquire)) {} int x = data;