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

Created on 2022-07-25.00:00:00 last changed 2 weeks ago

Messages

Date: 2022-07-30.12:40:00

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-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
2022-07-30 12:40:00adminsetmessages: + msg12662
2022-07-30 12:40:00adminsetmessages: + msg12661
2022-07-25 00:00:00admincreate