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

3417. Missing volatile atomic deprecations

Section: 33.5.8.2 [atomics.types.operations] Status: SG1 Submitter: Alisdair Meredith Opened: 2020-03-19 Last modified: 2020-09-06

Priority: 3

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

View all issues with SG1 status.

Discussion:

Paper P1831R1 aimed to deprecate all the atomic overloads for volatile qualified member function of std::atomic unless is_always_lock_free is true. There are a few omissions in the wording.

First, operator++ and operator-- are correctly constrained, but the deprecated overloads are not restored in Annex D, unlike the other member functions. I confirmed with the paper author this is an accidental oversight, and not an intended change of behavior for C++20.

Secondly, the wait/notify APIs were added after the initial wording For this paper was drafted, and the paper did not catch up. Again, I confirmed with the paper author that these functions should be similarly constrained and deprecated.

[2020-04-04 Issue Prioritization]

Priority to 3 after reflector discussion. The suggested wording was generally accepted, but there were considerable doubts that it is necessary to add deprecated functions of the new wait/notify functions instead of declaring only the non-volatile overloads. The wish was expressed that both SG1 and LEWG should express their opinion here.

Proposed resolution:

This wording is relative to N4861.

  1. Modify 33.5.8.2 [atomics.types.operations] as indicated:

    void wait(T old, memory_order order = memory_order::seq_cst) const volatile noexcept;
    void wait(T old, memory_order order = memory_order::seq_cst) const noexcept;
    

    Constraints: For the volatile overload of this function, is_always_lock_free is true.

    -29- Preconditions: […]

    […]

    void notify_one() volatile noexcept;
    void notify_one() noexcept;
    

    Constraints: For the volatile overload of this function, is_always_lock_free is true.

    -32- Effects: […]

    […]

    void notify_all() volatile noexcept;
    void notify_all() noexcept;
    

    Constraints: For the volatile overload of this function, is_always_lock_free is true.

    -34- Effects: […]

    […]

  2. Modify D.30.2 [depr.atomics.volatile], annex D, as indicated:

    If an atomic specialization has one of the following overloads, then that overload participates in overload resolution even if atomic<T>::is_always_lock_free is false:

    void store(T desired, memory_order order = memory_order::seq_cst) volatile noexcept;
    […]
    T* fetch_key(ptrdiff_t operand, memory_order order = memory_order::seq_cst) volatile noexcept;
    value_type operator++(int) volatile noexcept;
    value_type operator--(int) volatile noexcept;
    value_type operator++() volatile noexcept;
    value_type operator--() volatile noexcept;
    void wait(T old, memory_order order = memory_order::seq_cst) const volatile noexcept;
    void notify_one() volatile noexcept;
    void notify_all() volatile noexcept;