<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2138: atomic_flag::clear should not accept memory_order_consume</title>
<meta property="og:title" content="Issue 2138: atomic_flag::clear should not accept memory_order_consume">
<meta property="og:description" content="C++ library issue. Status: C++14">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2138.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#C++14">C++14</a> status.</em></p>
<h3 id="2138"><a href="lwg-defects.html#2138">2138</a>. <code>atomic_flag::clear</code> should not accept <code>memory_order_consume</code></h3>
<p><b>Section:</b> 32.5.10 <a href="https://wg21.link/atomics.flag">[atomics.flag]</a> <b>Status:</b> <a href="lwg-active.html#C++14">C++14</a>
 <b>Submitter:</b> Ben Viglietta <b>Opened:</b> 2012-03-08 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all other</b> <a href="lwg-index.html#atomics.flag">issues</a> in [atomics.flag].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++14">C++14</a> status.</p>
<p><b>Discussion:</b></p>

<p>
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3376.pdf">N3376</a> 32.5.10 <a href="https://wg21.link/atomics.flag">[atomics.flag]</a>&#47;7 says
this about <code>atomic_flag::clear</code>:
</p>
<blockquote><p>
<i>Requires</i>: The <code>order</code> argument shall not be <code>memory_order_acquire</code> or <code>memory_order_acq_rel</code>.
</p></blockquote>
<p>
In addition, <code>memory_order_consume</code> should be disallowed, since it doesn't meaningfully apply to store operations.  
It's already disallowed on the analogous <code>atomic&lt;T&gt;::store</code>. The proposed updated text would be:
</p>
<blockquote><p>
<i>Requires</i>: The <code>order</code> argument shall not be <ins><code>memory_order_consume</code>,</ins> 
<code>memory_order_acquire</code><ins>,</ins> or <code>memory_order_acq_rel</code>.
</p></blockquote>

<p><i>[2012, Portland: move to Review]</i></p>

<p>
Hans: this is a clear oversight.
</p>
<p>
Moved to review
</p>

<p><i>[2013-04-20, Bristol]</i></p>

<p>Accepted for the working paper</p>



<p id="res-2138"><b>Proposed resolution:</b></p>
<p><i>[This wording is relative to N3376.]</i></p>


<blockquote><pre>
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;
</pre><blockquote>
<p>
-7- <i>Requires</i>: The <code>order</code> argument shall not be <ins><code>memory_order_consume</code>,</ins> 
<code>memory_order_acquire</code><ins>,</ins> or <code>memory_order_acq_rel</code>.
<p/>
-8- <i>Effects</i>: Atomically sets the value pointed to by <code>object</code> or by <code>this</code> to false. Memory is affected
according to the value of <code>order</code>.
</p>
</blockquote>
</blockquote>






</body>
</html>
