C++ Logo

std-discussion

Advanced search

Removal of consume ordering and the [[carries_dependency]] attribute

From: Nate Eldredge <nate_at_[hidden]>
Date: Thu, 4 Sep 2025 16:20:09 +0000
The current C++26 draft functionally removes memory_order_consume from the memory model. To this end, we have [depr.atomics.order] (https://eel.is/c++draft/depr.atomics.order) which defines `std::memory_order_consume` as having identical effect to `std::memory_order_acquire`, and defines `std::kill_dependency` as a no-op. This maintains backward compatibility with C++23, as acquire is strictly stronger than consume, and matches what most if not all implementations were doing in practice.

But the remaining piece of consume ordering in C++23 and earlier was the [[carries_dependency]] attribute (see C++23 9.12.4 [dcl.attr.depend]). This does not appear to be mentioned anywhere in the C++26 draft, and I wonder if this is an oversight. Should [depr.atomics.order] additionally define [[carries_dependency]] as an attribute that has no effect?

Otherwise, it would be theoretically permissible for a C++26 implementation to define [[carries_dependency]] for itself with some incompatible semantics, thus breaking otherwise valid C++23 code.

Received on 2025-09-04 16:20:11