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

In the producer/consumer below using `release` on the store and `consume` (not `acquire`) on the load, what ordering does `memory_order_consume` guarantee, and why do real compilers undermine it?

std::atomic<int*> head{nullptr}; // Producer int* p = make_node(); head.store(p, std::memory_order_release); // Consumer int* q = head.load(std::memory_order_consume); if (q) use(*q); // *q is dependency-ordered after the load