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

On x86-64, a `std::atomic<int>::store(x, std::memory_order_seq_cst)` typically compiles to an instruction that is more expensive than a plain `mov`. Which instruction is emitted and why is it needed there but not for a release store?

std::atomic<int> a; a.store(5, std::memory_order_seq_cst);