This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Tentatively Ready status.
std::atomic_refSection: 32.5.7.2 [atomics.ref.ops] Status: Tentatively Ready Submitter: Brian Bi Opened: 2025-09-15 Last modified: 2025-10-20
Priority: Not Prioritized
View other active issues in [atomics.ref.ops].
View all other issues in [atomics.ref.ops].
View all issues with Tentatively Ready status.
Discussion:
Note 1 to 32.5.7.2 [atomics.ref.ops] states:
Hardware could require an object referenced by an
atomic_refto have stricter alignment (6.8.3 [basic.align]) than other objects of typeT. Further, whether operations on anatomic_refare lock-free could depend on the alignment of the referenced object. For example, lock-free operations onstd::complex<double>could be supported only if aligned to2*alignof(double).
By using the word "Further", the note misleadingly implies that required_alignment may
need to be greater than alignof(T) even before considering lock freedom, i.e., that
std::atomic_ref<T> may be completely unimplementable on given hardware if
the stricter alignment requirement is not met. However, that can never be true because
falling back to a lock-based implementation is always possible.
required_alignment and thus referenceable by an atomic_ref, operations could still fail
to be lock-free because there is a stricter alignment requirement that the object does not
meet. Such an interpretation is, however, at odds with p4.
The example given by the note is also confusing in that it does not necessarily demonstrate
a situation in which std::atomic_ref<T>::required_alignment is greater than
alignof(T).
In conclusion, this note appears to be a convoluted way of saying that, in order to ensure
that operations on atomic_ref<T> are lock-free, the implementation may
define required_alignment to a value greater than alignof(T). The note should be
modified to say this much more clearly.
[2025-10-20; Reflector poll.]
Set status to Tentatively Ready after five votes in favour during reflector poll. Also ask SG1 to take a look.
Proposed resolution:
This wording is relative to N5014.
Modify 32.5.7.2 [atomics.ref.ops] as indicated:
static constexpr size_t required_alignment;-1- The alignment required for an object to be referenced by an atomic reference, which is at least
-2- [Note 1:alignof(T).Hardware could require an object referenced by anAn implementation can choose to defineatomic_refto have stricter alignment (6.8.3 [basic.align]) than other objects of typeT. Further, whether operations on anatomic_refare lock-free could depend on the alignment of the referenced object. For example, lock-free operations onstd::complex<double>could be supported only if aligned to2*alignof(double)atomic_ref<T>::required_alignmentto a value greater thanalignof(T)in order to ensure that operations on all objects of typeatomic_ref<T>are lock-free. — end note]