diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/atomic%2Fatomic_var_init.html | |
new repository
Diffstat (limited to 'devdocs/c/atomic%2Fatomic_var_init.html')
| -rw-r--r-- | devdocs/c/atomic%2Fatomic_var_init.html | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/devdocs/c/atomic%2Fatomic_var_init.html b/devdocs/c/atomic%2Fatomic_var_init.html new file mode 100644 index 00000000..66208dac --- /dev/null +++ b/devdocs/c/atomic%2Fatomic_var_init.html @@ -0,0 +1,24 @@ + <h1 id="firstHeading" class="firstHeading">ATOMIC_VAR_INIT</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><stdatomic.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c11 t-until-c23"> <td> <pre data-language="c">#define ATOMIC_VAR_INIT(value) /* unspecified */</pre> +</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> <br><span class="t-mark">(deprecated in C17)</span> <br><span class="t-mark-rev t-until-c23">(removed in C23)</span> </td> </tr> </table> <p>Expands to an expression that can be used to initialize an atomic variable of the same type as <code>value</code>.</p> +<p>The initial value of atomic object of automatic storage duration that is not explicitly initialized is indeterminate. The default (zero) initialization of static and thread-local variables produces a valid value however.</p> +<p>When initializing an atomic variable, any concurrent access, even through an atomic operation, is a data race (it may happen if the address is immediately passed to another thread with a <code><a href="memory_order" title="c/atomic/memory order">memory_order_relaxed</a></code> operation).</p> +<h3 id="Notes"> Notes</h3> <p>This macro was a part of early draft design for C11 atomic types. It is not needed in C11, and is deprecated in C17 and removed in C23.</p> +<h3 id="Defect_reports"> Defect reports</h3> <p>The following behavior-changing defect reports were applied retroactively to previously published C standards.</p> +<table class="dsctable"> <tr> <th>DR </th> <th>Applied to </th> <th>Behavior as published </th> <th>Correct behavior </th> +</tr> <tr> <td> +<a rel="nofollow" class="external text" href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_485">DR 485</a> </td> <td>C11 </td> <td>the specification was redundant and contradictory to the core language </td> <td>fixed </td> +</tr> +</table> <h3 id="References"> References</h3> <ul> +<li> C17 standard (ISO/IEC 9899:2018): </li> +<ul><li> 7.17.2.1 The ATOMIC_VAR_INIT macro (p: 201) </li></ul> +<li> C11 standard (ISO/IEC 9899:2011): </li> +<ul><li> 7.17.2.1 The ATOMIC_VAR_INIT macro (p: 274) </li></ul> +</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="atomic_flag_init" title="c/atomic/ATOMIC FLAG INIT"> <span class="t-lines"><span>ATOMIC_FLAG_INIT</span></span></a></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> initializes a new <code><a href="http://en.cppreference.com/w/c/atomic/atomic_flag"><span class="kw917">atomic_flag</span></a></code> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/atomic/ATOMIC_VAR_INIT" title="cpp/atomic/ATOMIC VAR INIT">C++ documentation</a></span> for <code>ATOMIC_VAR_INIT</code> </td> +</tr> </table> <div class="_attribution"> + <p class="_attribution-p"> + © cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br> + <a href="https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT" class="_attribution-link">https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT</a> + </p> +</div> |
