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

2138. atomic_flag::clear should not accept memory_order_consume

Section: 32.5.10 [atomics.flag] Status: C++14 Submitter: Ben Viglietta Opened: 2012-03-08 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [atomics.flag].

View all issues with C++14 status.

Discussion:

N3376 32.5.10 [atomics.flag]/7 says this about atomic_flag::clear:

Requires: The order argument shall not be memory_order_acquire or memory_order_acq_rel.

In addition, memory_order_consume should be disallowed, since it doesn't meaningfully apply to store operations. It's already disallowed on the analogous atomic<T>::store. The proposed updated text would be:

Requires: The order argument shall not be memory_order_consume, memory_order_acquire, or memory_order_acq_rel.

[2012, Portland: move to Review]

Hans: this is a clear oversight.

Moved to review

[2013-04-20, Bristol]

Accepted for the working paper

Proposed resolution:

[This wording is relative to N3376.]

void atomic_flag_clear(volatile atomic_flag *object) noexcept;
void atomic_flag_clear(atomic_flag *object) noexcept;
void atomic_flag_clear_explicit(volatile atomic_flag *object, memory_order order) noexcept;
void atomic_flag_clear_explicit(atomic_flag *object, memory_order order) noexcept;
void atomic_flag::clear(memory_order order = memory_order_seq_cst) volatile noexcept;
void atomic_flag::clear(memory_order order = memory_order_seq_cst) noexcept;

-7- Requires: The order argument shall not be memory_order_consume, memory_order_acquire, or memory_order_acq_rel.

-8- Effects: Atomically sets the value pointed to by object or by this to false. Memory is affected according to the value of order.