<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3659: Consider ATOMIC_FLAG_INIT undeprecation</title>
<meta property="og:title" content="Issue 3659: Consider ATOMIC_FLAG_INIT undeprecation">
<meta property="og:description" content="C++ library issue. Status: C++23">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3659.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++23">C++23</a> status.</em></p>
<h3 id="3659"><a href="lwg-defects.html#3659">3659</a>. Consider <code>ATOMIC_FLAG_INIT</code> undeprecation</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++23">C++23</a>
 <b>Submitter:</b> Aaron Ballman <b>Opened:</b> 2022-01-18 <b>Last modified:</b> 2023-11-22</p>
<p><b>Priority: </b>3
</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++23">C++23</a> status.</p>
<p><b>Discussion:</b></p>
<p>
<a href="https://wg21.link/P0883R2" title=" Fixing Atomic Initialization">P0883R2</a> deprecated <code>ATOMTIC_VAR_INIT</code> and
<code>ATOMIC_FLAG_INIT</code> largely based on rationale from WG14. However, WG14
only deprecated <code>ATOMIC_VAR_INIT</code> because we were told by implementers
that <code>ATOMIC_FLAG_INIT</code> is still necessary for some platforms (platforms
for which "clear" is actually not all zero bits, which I guess exist).
<p/>
I'd like to explore whether WG21 should undeprecate <code>ATOMIC_FLAG_INIT</code>
as there was no motivation that I could find in the paper on the topic
or in the discussion at 
<a href="https://wiki.edg.com/bin/view/Wg21jacksonville2018/P0883R0">P0883R0 [Jacksonville 2018]</a>.
<p/>
One possible approach would be to undeprecate it from <code>&lt;stdatomic.h&gt;</code> only (C++ 
can still use the constructors from <code>&lt;atomic&gt;</code> and shared code can use the macros 
from <code>&lt;stdatomic.h&gt;</code>).
</p>

<p><i>[2022-01-30; Reflector poll]</i></p>

<p>
Set priority to 3 after reflector poll. Send to SG1.
</p>

<p><i>[2022-07-06; SG1 confirm the direction, Jonathan adds wording]</i></p>

<p>
"In response to LWG 3659, add ATOMIC_FLAG_INIT to &lt;stdatomic.h&gt; as undeprecated."
</p>
<table>
<tr><td>SF</td><td>F</td><td>N</td><td>A</td><td>SA</td></tr>
<tr><td>3</td><td>0</td><td>0</td><td>0</td><td>0</td></tr>
</table>
<p>
"In response to LWG 3659, undeprecate ATOMIC_FLAG_INIT in &lt;atomic&gt;."
</p>
<table>
<tr><td>SF</td><td>F</td><td>N</td><td>A</td><td>SA</td></tr>
<tr><td>2</td><td>3</td><td>1</td><td>0</td><td>0</td></tr>
</table>


<p><i>[2022-07-11; Reflector poll]</i></p>

<p>
Set status to Tentatively Ready after six votes in favour during reflector poll.
</p>

<p><i>[2022-07-15; LWG telecon: move to Ready]</i></p>


<p><i>[2022-07-25 Approved at July 2022 virtual plenary. Status changed: Ready &rarr; WP.]</i></p>



<p id="res-3659"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/N4910" title=" Working Draft, Standard for Programming Language C++">N4910</a>.
</p>

<ol>
<li>
<p>
Modify 32.5.2 <a href="https://wg21.link/atomics.syn">[atomics.syn]</a>, Header <code>&lt;atomic&gt;</code> synopsis,
as indicated:
</p>

<blockquote>
<pre>
void atomic_flag_notify_all(volatile atomic_flag*) noexcept;
void atomic_flag_notify_all(atomic_flag*) noexcept;
<ins>#define ATOMIC_FLAG_INIT <i>see below</i></ins>

// [atomics.fences], fences
extern "C" void atomic_thread_fence(memory_order) noexcept;
extern "C" void atomic_signal_fence(memory_order) noexcept;
</pre>
</blockquote>
</li>

<li>
<p>
Move the content of  [depr.atomics.flag] from Annex D to
the end of 32.5.10 <a href="https://wg21.link/atomics.flag">[atomics.flag]</a>.
</p>
<blockquote>
<pre>
#define ATOMIC_FLAG_INIT <i>see below</i>
</pre>
<blockquote>
<p>
<i>Remarks:</i> The macro <code>ATOMIC_FLAG_INIT</code> is defined in
such a way that it can be used to initialize an object of type
<code>atomic_flag</code> to the clear state. The macro can be used in the form:
</p>
<pre>
  atomic_flag guard = ATOMIC_FLAG_INIT;
</pre>
<p>
It is unspecified whether the macro can be used in other initialization
contexts.
For a complete static-duration object, that initialization shall be static.
</p>
</blockquote>
</blockquote>
</li>

<li>
<p>
Modify 32.5.12 <a href="https://wg21.link/stdatomic.h.syn">[stdatomic.h.syn]</a> C compatibility, as indicated:
</p>

<blockquote>
<pre>
using std::atomic_flag_clear;            <i>// see below</i>
using std::atomic_flag_clear_explicit;   <i>// see below</i>
<ins>#define ATOMIC_FLAG_INIT <i>see below</i></ins>

using std::atomic_thread_fence;          <i>// see below</i>
using std::atomic_signal_fence;          <i>// see below</i>
</pre>
</blockquote>
</li>

<li>
<p>
Modify D.23.1 <a href="https://wg21.link/depr.atomics.general">[depr.atomics.general]</a> in Annex D as indicated:
</p>

<blockquote>
<pre>
#define ATOMIC_VAR_INIT(value) <i>see below</i>

<del>#define ATOMIC_FLAG_INIT <i>see below</i></del>
}
</pre>
</blockquote>
</li>

</ol>






</body>
</html>
