summaryrefslogtreecommitdiff
path: root/devdocs/c/language%2Fattributes%2Freproducible.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/language%2Fattributes%2Freproducible.html
new repository
Diffstat (limited to 'devdocs/c/language%2Fattributes%2Freproducible.html')
-rw-r--r--devdocs/c/language%2Fattributes%2Freproducible.html22
1 files changed, 22 insertions, 0 deletions
diff --git a/devdocs/c/language%2Fattributes%2Freproducible.html b/devdocs/c/language%2Fattributes%2Freproducible.html
new file mode 100644
index 00000000..fa0bc584
--- /dev/null
+++ b/devdocs/c/language%2Fattributes%2Freproducible.html
@@ -0,0 +1,22 @@
+ <h1 id="firstHeading" class="firstHeading">C attribute: unsequenced, reproducible <span class="t-mark-rev t-since-c23">(since C23)</span>
+</h1> <p>Provides the compiler with information about the access of objects by a function such that certain properties of function calls can be deduced.</p>
+<h3 id="Syntax"> Syntax</h3> <table class="t-sdsc-begin"> <tr class="t-sdsc"> <td> <code>[[</code> <code>unsequenced</code> <code>]]</code><br><code>[[</code> <code>__unsequenced__</code> <code>]]</code> </td> <td> (1) </td> <td class="t-sdsc-nopad"> </td>
+</tr> <tr class="t-sdsc"> <td> <code>[[</code> <code>reproducible</code> <code>]]</code><br><code>[[</code> <code>__reproducible__</code> <code>]]</code> </td> <td> (2) </td> <td class="t-sdsc-nopad"> </td>
+</tr>
+</table> <div class="t-li1">
+<span class="t-li">1)</span> Indicates that a function is effectless, idempotent, stateless, and independent</div> <div class="t-li1">
+<span class="t-li">2)</span> Indicates that a function is effectless and idempotent</div> <h3 id="Explanation"> Explanation</h3> <p>These attributes apply to a function declarator or to a type specifier that has a function type. The corresponding attribute is a property of the function type.</p>
+<h4 id="Effectless"> Effectless</h4> <p>An evaluation of a function call is effectless if any store operation that is sequenced during the call is the modification of an object that synchronizes with the call; if additionally the operation is observable, all access to the object must be based on a unique pointer parameter of the function.</p>
+<h4 id="Idempotent"> Idempotent</h4> <p>An evaluation <span class="t-spar">E</span> is idempotent if a second evaluation of <span class="t-spar">E</span> can be sequenced immediately after the original one without changing the resulting value, if any, or the observable state of the execution.</p>
+<h4 id="Stateless"> Stateless</h4> <p>A function <span class="t-spar">F</span> is stateless if any definition of an object of static or thread <a href="../storage_duration" title="c/language/storage duration">storage duration</a> in <span class="t-spar">F</span> or in a function that is called by <span class="t-spar">F</span> is <code>const</code> but not <code>volatile</code> qualified.</p>
+<h4 id="Independent"> Independent</h4> <p>A function <span class="t-spar">F</span> is independent if for any object <span class="t-spar">X</span> that is observed by a call to <span class="t-spar">F</span> through an lvalue that is not based on a parameter of the call, all accesses to <span class="t-spar">X</span> in all calls to <span class="t-spar">F</span> during the same program execution observe the same value; otherwise if the access is based on a pointer parameter, there shall be a unique such pointer parameter <span class="t-spar">P</span> such that any access to <span class="t-spar">X</span> shall be to an lvalue that is based on <span class="t-spar">P</span>.</p>
+<p>An object <span class="t-spar">X</span> is observed by a function call if both synchronize, if <span class="t-spar">X</span> is not local to the call, if <span class="t-spar">X</span> has a lifetime that starts before the function call, and if an access of <span class="t-spar">X</span> is sequenced during the call; the last value of <span class="t-spar">X</span>, if any, that is stored before the call is said to be the value of <span class="t-spar">X</span> that is observed by the call.</p>
+<h3 id="Notes"> Notes</h3> <p>These attributes exist for the purpose of compiler optimization.</p>
+<p>If a function is reproducible, multiple subsequent calls can be treated as a single call.</p>
+<p>If a function is unsequenced, multiple subsequent calls can be treated as a single call, and the calls can be parallelized and reordered arbitrarily.</p>
+<div class="_attribution">
+ <p class="_attribution-p">
+ &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
+ <a href="https://en.cppreference.com/w/c/language/attributes/reproducible" class="_attribution-link">https://en.cppreference.com/w/c/language/attributes/reproducible</a>
+ </p>
+</div>