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

3659. Consider ATOMIC_FLAG_INIT undeprecation

Section: 33.5.10 [atomics.flag] Status: WP Submitter: Aaron Ballman Opened: 2022-01-18 Last modified: 2023-02-07

Priority: 3

View all other issues in [atomics.flag].

View all issues with WP status.

Discussion:

P0883R2 deprecated ATOMTIC_VAR_INIT and ATOMIC_FLAG_INIT largely based on rationale from WG14. However, WG14 only deprecated ATOMIC_VAR_INIT because we were told by implementers that ATOMIC_FLAG_INIT is still necessary for some platforms (platforms for which "clear" is actually not all zero bits, which I guess exist).

I'd like to explore whether WG21 should undeprecate ATOMIC_FLAG_INIT as there was no motivation that I could find in the paper on the topic or in the discussion at P0883R0 [Jacksonville 2018].

One possible approach would be to undeprecate it from <stdatomic.h> only (C++ can still use the constructors from <atomic> and shared code can use the macros from <stdatomic.h>).

[2022-01-30; Reflector poll]

Set priority to 3 after reflector poll. Send to SG1.

[2022-07-06; SG1 confirm the direction, Jonathan adds wording]

"In response to LWG 3659, add ATOMIC_FLAG_INIT to <stdatomic.h> as undeprecated."

SFFNASA
30000

"In response to LWG 3659, undeprecate ATOMIC_FLAG_INIT in <atomic>."

SFFNASA
23100

[2022-07-11; Reflector poll]

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

[2022-07-15; LWG telecon: move to Ready]

[2022-07-25 Approved at July 2022 virtual plenary. Status changed: Ready → WP.]

Proposed resolution:

This wording is relative to N4910.

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

    void atomic_flag_notify_all(volatile atomic_flag*) noexcept;
    void atomic_flag_notify_all(atomic_flag*) noexcept;
    #define ATOMIC_FLAG_INIT see below
    
    // [atomics.fences], fences
    extern "C" void atomic_thread_fence(memory_order) noexcept;
    extern "C" void atomic_signal_fence(memory_order) noexcept;
    
  2. Move the content of [depr.atomics.flag] from Annex D to the end of 33.5.10 [atomics.flag].

    #define ATOMIC_FLAG_INIT see below
    

    Remarks: The macro ATOMIC_FLAG_INIT is defined in such a way that it can be used to initialize an object of type atomic_flag to the clear state. The macro can be used in the form:

      atomic_flag guard = ATOMIC_FLAG_INIT;
    

    It is unspecified whether the macro can be used in other initialization contexts. For a complete static-duration object, that initialization shall be static.

  3. Modify 33.5.12 [stdatomic.h.syn] C compatibility, as indicated:

    using std::atomic_flag_clear;            // see below
    using std::atomic_flag_clear_explicit;   // see below
    #define ATOMIC_FLAG_INIT see below
    
    using std::atomic_thread_fence;          // see below
    using std::atomic_signal_fence;          // see below
    
  4. Modify D.30.1 [depr.atomics.general] in Annex D as indicated:

    #define ATOMIC_VAR_INIT(value) see below
    
    #define ATOMIC_FLAG_INIT see below
    }