<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 1473: Incomplete memory order specifications</title>
<meta property="og:title" content="Issue 1473: Incomplete memory order specifications">
<meta property="og:description" content="C++ library issue. Status: NAD">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue1473.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#NAD">NAD</a> status.</em></p>
<h3 id="1473"><a href="lwg-closed.html#1473">1473</a>. Incomplete memory order specifications</h3>
<p><b>Section:</b> 32.5.8.2 <a href="https://wg21.link/atomics.types.operations">[atomics.types.operations]</a> <b>Status:</b> <a href="lwg-active.html#NAD">NAD</a>
 <b>Submitter:</b> INCITS <b>Opened:</b> 2010-08-25 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View other</b> <a href="lwg-index-open.html#atomics.types.operations">active issues</a> in [atomics.types.operations].</p>
<p><b>View all other</b> <a href="lwg-index.html#atomics.types.operations">issues</a> in [atomics.types.operations].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#NAD">NAD</a> status.</p>
<p><b>Discussion:</b></p>
<p><b>Addresses US-172</b></p>

<p>
As of 32.5.8.2 <a href="https://wg21.link/atomics.types.operations">[atomics.types.operations]</a> p. 9, 13, 17, 20:
<p/>
The order specifications are incomplete because the non-<code>_explicit</code>
functions do not have such parameters.
<p/>
Add a new sentence: "If the program does not specify an order, it shall be
<code>memory_order_seq_cst</code>." Or perhaps: "The non-_explicit
non-member functions shall affect memory as though they were _explicit with
<code>memory_order_seq_cst</code>."
</p>

<p><i>[
2010 Batavia
]</i></p>

<p>
The Concurrency subgroup reviewed this, and deemed it NAD according to
32.5.8.2 <a href="https://wg21.link/atomics.types.operations">[atomics.types.operations]</a> paragraph 2, bullet 4. 
</p>

<p><b>Rationale:</b></p><p>The working paper is correct as written.</p>



<p id="res-1473"><b>Proposed resolution:</b></p>
<ol>
<li>Change 32.5.8.2 <a href="https://wg21.link/atomics.types.operations">[atomics.types.operations]</a> p. 9 as indicated:
<blockquote><pre>
void atomic_store(volatile A* object, C desired);
void atomic_store(A* object, C desired);
void atomic_store_explicit(volatile A *object, C desired, memory_order order);
void atomic_store_explicit(A* object, C desired, memory_order order);
void A::store(C desired, memory_order order = memory_order_seq_cst) volatile;
void A::store(C desired, memory_order order = memory_order_seq_cst);
</pre><blockquote><p>
8 <em>Requires</em>: The order argument shall not be <code>memory_order_consume</code>, <code>memory_order_acquire</code>, nor
<code>memory_order_acq_rel</code>.
<p/>
9 <em>Effects</em>: Atomically replaces the value pointed to by <code>object</code> or by this with the value of <code>desired</code>.
Memory is affected according to the value of <code>order</code>. <ins>If the program does not specify an order, it shall be
<code>memory_order_seq_cst</code>.</ins>
</p>
</blockquote></blockquote>
</li>
<li>Change 32.5.8.2 <a href="https://wg21.link/atomics.types.operations">[atomics.types.operations]</a> p. 13 as indicated:
<blockquote><pre>
C atomic_load(const volatile A* object);
C atomic_load(const A* object);
C atomic_load_explicit(const volatile A* object, memory_order);
C atomic_load_explicit(const A* object, memory_order);
C A::load(memory_order order = memory_order_seq_cst) const volatile;
C A::load(memory_order order = memory_order_seq_cst) const;
</pre><blockquote><p>
12 <em>Requires</em>: The order argument shall not be <code>memory_order_release</code> nor <code>memory_order_acq_rel</code>.
<p/>
13 <em>Effects</em>: Memory is affected according to the value of <code>order</code>. <ins>If the program does not specify an order, it shall be
<code>memory_order_seq_cst</code>.</ins>
<p/>
14 <em>Returns</em>: Atomically returns the value pointed to by <code>object</code> or by <code>this</code>.
</p>
</blockquote></blockquote>
</li>
<li>Change 32.5.8.2 <a href="https://wg21.link/atomics.types.operations">[atomics.types.operations]</a> p. 17 as indicated:
<blockquote><pre>
C atomic_exchange(volatile A* object, C desired);
C atomic_exchange(A* object, C desired);
C atomic_exchange_explicit(volatile A* object, C desired, memory_order);
C atomic_exchange_explicit(A* object, C desired, memory_order);
C A::exchange(C desired, memory_order order = memory_order_seq_cst) volatile;
C A::exchange(C desired, memory_order order = memory_order_seq_cst);
</pre><blockquote><p>
17 <em>Effects</em>: Atomically replaces the value pointed to by <code>object</code> or by <code>this</code> with <code>desired</code>. Memory
is affected according to the value of <code>order</code>. These operations are atomic read-modify-write operations
(1.10). <ins>If the program does not specify an order, it shall be <code>memory_order_seq_cst</code>.</ins>
<p/>
18 <em>Returns</em>: Atomically returns the value pointed to by <code>object</code> or by <code>this</code> immediately before the effects.
</p>
</blockquote></blockquote>
</li>
<li>Change 32.5.8.2 <a href="https://wg21.link/atomics.types.operations">[atomics.types.operations]</a> p. 20 as indicated:
<blockquote><pre>
bool atomic_compare_exchange_weak(volatile A* object, C * expected, C desired);
bool atomic_compare_exchange_weak(A* object, C * expected, C desired);
bool atomic_compare_exchange_strong(volatile A* object, C * expected, C desired);
bool atomic_compare_exchange_strong(A* object, C * expected, C desired);
bool atomic_compare_exchange_weak_explicit(volatile A* object, C * expected, C desired,
  memory_order success, memory_order failure);
bool atomic_compare_exchange_weak_explicit(A* object, C * expected, C desired,
  memory_order success, memory_order failure);
bool atomic_compare_exchange_strong_explicit(volatile A* object, C * expected, C desired,
  memory_order success, memory_order failure);
bool atomic_compare_exchange_strong_explicit(A* object, C * expected, C desired,
  memory_order success, memory_order failure);
bool A::compare_exchange_weak(C &amp; expected, C desired,
  memory_order success, memory_order failure) volatile;
bool A::compare_exchange_weak(C &amp; expected, C desired,
  memory_order success, memory_order failure);
bool A::compare_exchange_strong(C &amp; expected, C desired,
  memory_order success, memory_order failure) volatile;
bool A::compare_exchange_strong(C &amp; expected, C desired,
  memory_order success, memory_order failure);
bool A::compare_exchange_weak(C &amp; expected, C desired,
  memory_order order = memory_order_seq_cst) volatile;
bool A::compare_exchange_weak(C &amp; expected, C desired,
  memory_order order = memory_order_seq_cst);
bool A::compare_exchange_strong(C &amp; expected, C desired,
  memory_order order = memory_order_seq_cst) volatile;
bool A::compare_exchange_strong(C &amp; expected, C desired,
  memory_order order = memory_order_seq_cst);
</pre><blockquote><p>
19 <em>Requires</em>: The <code>failure</code> argument shall not be <code>memory_order_release</code> nor <code>memory_order_acq_rel</code>.
The <code>failure</code> argument shall be no stronger than the success argument.
<p/>
20 <em>Effects</em>: Atomically, compares the contents of the memory pointed to by <code>object</code> or by <code>this</code> for equality
with that in <code>expected</code>, and if true, replaces the contents of the memory pointed to by <code>object</code> or by
<code>this</code> with that in <code>desired</code>, and if false, updates the contents of the memory in expected with the
contents of the memory pointed to by <code>object</code> or by <code>this</code>. Further, if the comparison is true, memory
is affected according to the value of <code>success</code>, and if the comparison is false, memory is affected
according to the value of <code>failure</code>. When only one <code>memory_order</code> argument is supplied, the value of
<code>success</code> is <code>order</code>, and the value of <code>failure</code> is <code>order</code> except that a value of 
<code>memory_order_acq_rel</code> shall be replaced by the value <code>memory_order_acquire</code> and a value of 
<code>memory_order_release</code> shall be replaced by the value <code>memory_order_relaxed</code>. <ins>If 
the program does not specify an order, it shall be <code>memory_order_seq_cst</code>.</ins> If the operation returns <code>true</code>, 
these operations are atomic read-modify-write operations (1.10). Otherwise, these operations are atomic load operations.
<p/>
[..]
</p>
</blockquote></blockquote>
</li>
</ol>





</body>
</html>
