Title
Missing volatile atomic deprecations
Status
open
Section
[atomics.types.operations]
Submitter
Alisdair Meredith

Created on 2020-03-19.00:00:00 last changed 57 months ago

Messages

Date: 2020-04-24.18:46:57

Proposed resolution:

This wording is relative to N4861.

  1. Modify [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 [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;
    
Date: 2020-04-04.00:00:00

[ 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.

Date: 2020-03-19.00:00:00

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.

History
Date User Action Args
2020-04-04 20:27:25adminsetstatus: lewg -> open
2020-04-04 19:04:26adminsetmessages: + msg11190
2020-04-04 19:04:26adminsetstatus: new -> lewg
2020-03-29 10:33:48adminsetmessages: + msg11172
2020-03-19 00:00:00admincreate