Search⌘ K

std::mem_order_consume

Understand the challenges and current compiler behavior of std::memory_order_consume in C++. Learn how it compares with release-acquire ordering, the synchronization guarantees it provides, and why compilers map it to memory_order_acquire despite its intended weaker constraints.

Introduction

That is for two reasons that std::memory_order_consume is the most legendary of the six memory models: first, std::memory_order_consume is extremely hard to understand, and second - which may change in the future - no compiler currently supports it. With C++17 the situation gets even worse. Here is the official wording: “The specification of release-consume ordering is being revised, and the use of memory_order_consume is temporarily discouraged.”

How can it be that a compiler that implements the C++11 standard doesn’t support the memory model std::memory_order_consume? The answer is that the compiler maps std::memory_order_consume to std::memory_order_acquire. This ...