ATOMIC_FLAG_INIT
undeprecationSection: 32.5.10 [atomics.flag] Status: C++23 Submitter: Aaron Ballman Opened: 2022-01-18 Last modified: 2023-11-22
Priority: 3
View all other issues in [atomics.flag].
View all issues with C++23 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).
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."
SF | F | N | A | SA |
3 | 0 | 0 | 0 | 0 |
"In response to LWG 3659, undeprecate ATOMIC_FLAG_INIT in <atomic>."
SF | F | N | A | SA |
2 | 3 | 1 | 0 | 0 |
[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.
Modify 32.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;
Move the content of [depr.atomics.flag] from Annex D to the end of 32.5.10 [atomics.flag].
#define ATOMIC_FLAG_INIT see belowRemarks: The macro
ATOMIC_FLAG_INIT
is defined in such a way that it can be used to initialize an object of typeatomic_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.
Modify 32.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
Modify D.22.1 [depr.atomics.general] in Annex D as indicated:
#define ATOMIC_VAR_INIT(value) see below#define ATOMIC_FLAG_INIT see below}