<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3417: Missing volatile atomic deprecations</title>
<meta property="og:title" content="Issue 3417: Missing volatile atomic deprecations">
<meta property="og:description" content="C++ library issue. Status: SG1">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3417.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#SG1">SG1</a> status.</em></p>
<h3 id="3417"><a href="lwg-active.html#3417">3417</a>. Missing <code>volatile</code> atomic deprecations</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#SG1">SG1</a>
 <b>Submitter:</b> Alisdair Meredith <b>Opened:</b> 2020-03-19 <b>Last modified:</b> 2020-09-06</p>
<p><b>Priority: </b>3
</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#SG1">SG1</a> status.</p>
<p><b>Discussion:</b></p>
<p>
Paper <a href="https://wg21.link/p1831r1">P1831R1</a> aimed to deprecate all 
the atomic overloads for <code>volatile</code> qualified member function of 
<code>std::atomic</code> unless <code>is_always_lock_free</code> is <code>true</code>. 
There are a few omissions in the wording.
<p/>
First, <code>operator++</code> and <code>operator--</code> are correctly constrained, 
but the deprecated overloads are not restored in Annex D, unlike the other
member functions. I confirmed with the paper author this is an accidental 
oversight, and not an intended change of behavior for C++20.
<p/>
Secondly, the wait/notify APIs were added after the initial wording
For this paper was drafted, and the paper did not catch up. Again, I 
confirmed with the paper author that these functions should be
similarly constrained and deprecated.
</p>

<p><i>[2020-04-04 Issue Prioritization]</i></p>

<p>Priority to 3 after reflector discussion. The suggested wording was generally accepted, but there
were considerable doubts that it is necessary to add deprecated functions of the new <code>wait/notify</code>
functions instead of declaring only the non-volatile overloads. The wish was expressed that both SG1 and 
LEWG should express their opinion here.</p>


<p id="res-3417"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/n4861">N4861</a>.
</p>

<ol>
<li><p>Modify 32.5.8.2 <a href="https://wg21.link/atomics.types.operations">[atomics.types.operations]</a> as indicated:</p>

<blockquote>
<pre>
void wait(T old, memory_order order = memory_order::seq_cst) const volatile noexcept;
void wait(T old, memory_order order = memory_order::seq_cst) const noexcept;
</pre>
<blockquote>
<p>
<ins><i>Constraints:</i> For the <code>volatile</code> overload of this function, <code>is_always_lock_free</code> is <code>true</code>.</ins>
<p/>
-29- <i>Preconditions:</i> [&hellip;]
<p/>
[&hellip;]
</p>
</blockquote>
<pre>
void notify_one() volatile noexcept;
void notify_one() noexcept;
</pre>
<blockquote>
<p>
<ins><i>Constraints:</i> For the <code>volatile</code> overload of this function, <code>is_always_lock_free</code> is <code>true</code>.</ins>
<p/>
-32- <i>Effects:</i> [&hellip;]
<p/>
[&hellip;]
</p>
</blockquote>
<pre>
void notify_all() volatile noexcept;
void notify_all() noexcept;
</pre>
<blockquote>
<p>
<ins><i>Constraints:</i> For the <code>volatile</code> overload of this function, <code>is_always_lock_free</code> is <code>true</code>.</ins>
<p/>
-34- <i>Effects:</i> [&hellip;]
<p/>
[&hellip;]
</p>
</blockquote>
</blockquote>
</li>

<li><p>Modify D.23.2 <a href="https://wg21.link/depr.atomics.volatile">[depr.atomics.volatile]</a>, annex D, as indicated:</p>

<blockquote>
<p>
If an atomic specialization has one of the following overloads, then that overload participates in overload
resolution even if <code>atomic&lt;T&gt;::is_always_lock_free</code> is <code>false</code>:
</p>
<blockquote>
<pre>
void store(T desired, memory_order order = memory_order::seq_cst) volatile noexcept;
[&hellip;]
T* fetch_<i>key</i>(ptrdiff_t operand, memory_order order = memory_order::seq_cst) volatile noexcept;
<ins>value_type operator++(int) volatile noexcept;
value_type operator--(int) volatile noexcept;
value_type operator++() volatile noexcept;
value_type operator--() volatile noexcept;
void wait(T old, memory_order order = memory_order::seq_cst) const volatile noexcept;
void notify_one() volatile noexcept;
void notify_all() volatile noexcept;</ins>
</pre>
</blockquote>
</blockquote>
</li>

</ol>




</body>
</html>
