This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4647. Clarify whether an atomic operation is the function call expression or an evaluation within the invocation

Section: 32.5.8.2 [atomics.types.operations] Status: New Submitter: jim x Opened: 2026-11-30 Last modified: 2026-12-04

Priority: Not Prioritized

View other active issues in [atomics.types.operations].

View all other issues in [atomics.types.operations].

View all issues with New status.

Discussion:

Consider the following example:

#include <atomic>

int main() 
{
  std::atomic<int> value = 1;
  auto r = value.load() + value.load();
}

In this example, it is intuitively expected that the two atomic load operations are indeterminately sequenced with respect to each other, rather than being unsequenced.

The intended rule to establish this ordering is 6.10.1 [intro.execution] p12:

For each function invocation F, each evaluation that does not occur within F […] is either sequenced before all evaluations that occur within F or sequenced after all evaluations that occur within F; […]

However, according to 6.10.1 [intro.execution] p10:

Except where noted, evaluations of operands of individual operators and of subexpressions of individual expressions are unsequenced.

The function call expressions themselves (the two instances of value.load()) are subexpressions of the operands of the + operator. A function call expression does not occur within the function invocation it initiates.

If the "atomic operation" (the actual memory load) is interpreted as the evaluation of the function call expression itself, 6.10.1 [intro.execution] p12 would not apply between the two loads, leaving them formally unsequenced under 6.10.1 [intro.execution] p10.

Conversely, if the atomic operation is understood to be a hypothetical evaluation that occurs within the function body of the invoked function, then 6.10.1 [intro.execution] p12 successfully orders the evaluations occurring within the first invocation relative to those in the second invocation, making them indeterminately sequenced.

Since standard library atomic operations are often implemented via compiler intrinsics/builtins, the current wording in 32.5.8.2 [atomics.types.operations] does not make it sufficiently clear whether the effects (the atomic read/write) constitute evaluations occurring within a function invocation.

Suggested Resolution:

Clarify in 32.5.8.1 [atomics.types.generic.general] (or 32.5.8.2 [atomics.types.operations]) that an atomic operation is modeled as an evaluation (or a set of evaluations taken as a whole) occurring within the corresponding function invocation, ensuring that 6.10.1 [intro.execution] p12 guarantees they are indeterminately sequenced when invoked within unsequenced subexpressions.

Proposed resolution: