diff options
Diffstat (limited to 'devdocs/c/language%2Fas_if.html')
| -rw-r--r-- | devdocs/c/language%2Fas_if.html | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/devdocs/c/language%2Fas_if.html b/devdocs/c/language%2Fas_if.html new file mode 100644 index 00000000..19cace76 --- /dev/null +++ b/devdocs/c/language%2Fas_if.html @@ -0,0 +1,20 @@ + <h1 id="firstHeading" class="firstHeading">As-if rule</h1> <p>Allows any and all code transformations that do not change the observable behavior of the program.</p> +<h3 id="Explanation"> Explanation</h3> <p>The C compiler is permitted to perform any changes to the program as long as the following remains true:</p> +<table class="t-rev-begin"> <tr class="t-rev t-until-c11"> +<td> <span class="t-li">1)</span> At every <a href="eval_order" title="c/language/eval order">sequence point</a>, the values of all <a href="volatile" title="c/language/volatile">volatile</a> objects are stable (previous evaluations are complete, new evaluations not started). </td> <td><span class="t-mark-rev t-until-c11">(until C11)</span></td> +</tr> <tr class="t-rev t-since-c11"> +<td> <span class="t-li">1)</span> Accesses (reads and writes) to <a href="volatile" title="c/language/volatile">volatile</a> objects occur strictly according to the semantics of the expressions in which they occur. In particular, they are <a href="../atomic/memory_order" title="c/atomic/memory order">not reordered</a> with respect to other volatile accesses on the same thread. </td> <td><span class="t-mark-rev t-since-c11">(since C11)</span></td> +</tr> </table> <div class="t-li1"> +<span class="t-li">2)</span> At program termination, data written to files is exactly as if the program was executed as written.</div> <div class="t-li1"> +<span class="t-li">3)</span> Prompting text which is sent to interactive devices will be shown before the program waits for input.</div> <table class="t-rev-begin"> <tr class="t-rev t-since-c99"> +<td> <span class="t-li">4)</span> If the pragma <a href="../preprocessor/impl#Standard_pragmas" title="c/preprocessor/impl"><code> #pragma STDC FENV_ACCESS</code></a> is supported and is set to <code>ON</code>, the changes to the <a href="../numeric/fenv" title="c/numeric/fenv">floating-point environment</a> (floating-point exceptions and rounding modes) are guaranteed to be observed by the floating-point arithmetic operators and function calls as if executed as written, except that <ul> +<li> the result of any floating-point expression other than cast and assignment may have range and precision of a floating-point type different from the type of the expression (see <code><a href="../types/limits/flt_eval_method" title="c/types/limits/FLT EVAL METHOD">FLT_EVAL_METHOD</a></code>), </li> +<li> notwithstanding the above, intermediate results of any floating-point expression may be calculated as if to infinite range and precision (unless <a href="../preprocessor/impl#Standard_pragmas" title="c/preprocessor/impl"><code> #pragma STDC FP_CONTRACT</code></a> is <code>OFF</code>).</li> +</ul> </td> <td><span class="t-mark-rev t-since-c99">(since C99)</span></td> +</tr> </table> <h3 id="Notes"> Notes</h3> <h3 id="See_also"> See also</h3> <ul><li> <a href="eval_order" title="c/language/eval order">Order of evaluation</a> </li></ul> <table class="t-dsc-begin"> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/language/as_if" title="cpp/language/as if">C++ documentation</a></span> for <span class=""><span>as-if rule</span></span> </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/language/as_if" class="_attribution-link">https://en.cppreference.com/w/c/language/as_if</a> + </p> +</div> |
