3999. P0439R0 changed the value category of memory order constants

Section: 32.5.4 [atomics.order] Status: New Submitter: Jiang An Opened: 2023-10-18 Last modified: 2023-11-03

Priority: 4

View other active issues in [atomics.order].

View all other issues in [atomics.order].

View all issues with New status.

Discussion:

P0439R0 made std::memory_order an scoped enumeration type. However, it also changed former enumerators (std::memory_order_seq_cst) to constexpr variables.

It is unclear the additional change is intended while it presumably bothered nobody in practice. Given there is using enum (P1099R5) in C++20, it may be better to keep these constants being prvalues.

[2023-11-02; Reflector poll]

Set priority to 4 after reflector poll.

Proposed resolution:

This wording is relative to N4964.

  1. Modify 32.5.2 [atomics.syn], header <atomic> synopsis, as indicated:

    namespace std {
      // 32.5.4 [atomics.order], order and consistency
      enum class memory_order : unspecified;                        // freestanding
      inline constexpr memory_order memory_order_relaxed = memory_order::relaxedusing memory_order::memory_order_relaxed; // freestanding
      inline constexpr memory_order memory_order_consume = memory_order::consumeusing memory_order::memory_order_consume; // freestanding
      inline constexpr memory_order memory_order_acquire = memory_order::acquireusing memory_order::memory_order_acquire; // freestanding
      inline constexpr memory_order memory_order_release = memory_order::releaseusing memory_order::memory_order_release; // freestanding
      inline constexpr memory_order memory_order_acq_rel = memory_order::acq_relusing memory_order::memory_order_acq_rel; // freestanding
      inline constexpr memory_order memory_order_seq_cst = memory_order::seq_cstusing memory_order::memory_order_seq_cst; // freestanding
      
      […]
    }
    […]
    
  2. Modify 32.5.4 [atomics.order] as indicated:

    namespace std {
      enum class memory_order : unspecified {
        relaxed, consume, acquire, release, acq_rel, seq_cst,
        memory_order_relaxed = relaxed, memory_order_consume = consume, memory_order_acquire = acquire,
        memory_order_release = release, memory_order_acq_rel = acq_rel, memory_order_seq_cst = seq_cst
      };
    }