Title
std::atomic_wait and its friends lack noexcept
Status
c++23
Section
[atomics.syn]
Submitter
Jiang An

Created on 2022-07-25.00:00:00 last changed 13 months ago

Messages

Date: 2022-11-17.00:42:33

Proposed resolution:

This wording is relative to N4910.

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

    […]
    template<class T>
      void atomic_wait(const volatile atomic<T>*, typename atomic<T>::value_type) noexcept;
    template<class T>
      void atomic_wait(const atomic<T>*, typename atomic<T>::value_type) noexcept;
    template<class T>
      void atomic_wait_explicit(const volatile atomic<T>*, typename atomic<T>::value_type,
                                memory_order) noexcept;
    template<class T>
      void atomic_wait_explicit(const atomic<T>*, typename atomic<T>::value_type,
                                memory_order) noexcept;
    template<class T>
      void atomic_notify_one(volatile atomic<T>*) noexcept;
    template<class T>
      void atomic_notify_one(atomic<T>*) noexcept;
    template<class T>
      void atomic_notify_all(volatile atomic<T>*) noexcept;
    template<class T>
      void atomic_notify_all(atomic<T>*) noexcept;
    […]
    
Date: 2022-11-12.00:00:00

[ 2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Voting → WP. ]

Date: 2022-08-15.00:00:00

[ 2022-08-23; Reflector poll ]

Set status to Tentatively Ready after six votes in favour during reflector poll.

"Technically there's a difference between these and the member functions - the pointer can be null - but we don't seem to have let that stop us from adding noexcept to the rest of these functions."

Date: 2022-07-15.00:00:00

[ 2022-07-30; Daniel provides wording ]

Date: 2022-07-25.00:00:00

Currently function templates std::atomic_wait, std::atomic_wait_explicit, std::atomic_notify_one, and std::atomic_notify_all are not noexcept in the Working Draft, but the equivalent member functions are all noexcept. I think these function templates should be specified as noexcept, in order to be consistent with the std::atomic_flag_* free functions, the corresponding member functions, and other std::atomic_* function templates.

Mainstream implementations (libc++, libstdc++, and MSVC STL) have already added noexcept to them.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2022-11-17 00:42:33adminsetmessages: + msg13058
2022-11-17 00:42:33adminsetstatus: voting -> wp
2022-11-08 03:46:49adminsetstatus: ready -> voting
2022-08-23 15:24:34adminsetmessages: + msg12693
2022-08-23 15:24:34adminsetstatus: new -> ready
2022-07-30 12:40:00adminsetmessages: + msg12662
2022-07-30 12:40:00adminsetmessages: + msg12661
2022-07-25 00:00:00admincreate