<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">GCC (5.1) doesn’t generate any warnings, and this code when compiled with GCC and executed under Valgrind doesn’t have any complaint from Valgrind. We have not upgraded to GCC 7.1 yet and are planning to do so later this summer.</div><div class=""><font face="PT Mono" class=""><br class=""></font></div><font face="PT Mono" class="">warning: unsequenced modification and access to 'tmp0' [-Wunsequenced]<br class="">        if ( ((tmp0=f1 == -2143289343,false)) || !(tmp0) )<br class="">                   ^                              ~</font><div class=""><font face="PT Mono" class="">warning: unsequenced modification and access to 'tmp0' [-Wunsequenced]<br class="">      if ( (!((tmp0=f1 == f3_1,false)) && tmp0) ) {</font><br class=""><div style="margin: 0px; font-family: 'PT Mono';" class="">                   ^                      ~~~~</div><div class=""><div style="margin: 0px; font-family: 'PT Mono';" class="">2 warnings generated.</div></div><div class=""><br class=""></div>In each case the operand on the left is setting the value of tmp0 which is then tested on the right side of the operand. In either case I don’t see how the ‘As If’ rule from the standard applies. Shouldn’t execution order left to right take precedence in this situation?</div><div class=""><br class=""></div><div class="">1- Is it actually possible at some optimization level that the compiler may generate code where the right side of the expression is executed before the left side?</div><div class="">2 - If (1) then is there some switch I can use to disable this specific optimization level?</div><div class="">3 - Is there some way to disable the warning if there actually exists no way that (1) may happen?</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">    </span>David</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">1.9  Program execution  [intro.execution]<br class=""><br class="">The semantic descriptions in this International Standard define a<br class="">parameterized nondeterministic abstract machine. This International<br class="">Standard places no requirement on the structure of conforming<br class="">implementations.  In particular, they need not copy or emulate the<br class="">structure of the abstract machine. Rather, conforming implementations<br class="">are required to emulate (only) the observable behavior of the abstract<br class="">machine as explained below.5<br class=""><br class="">5) This provision is sometimes called the “as-if” rule, because an<br class="">implementation is free to disregard any requirement of this<br class="">International Standard as long as the result is as if the requirement<br class="">had been obeyed, as far as can be determined from the observable<br class="">behavior of the program. For instance, an actual implementation need<br class="">not evaluate part of an expression if it can deduce that its value is<br class="">not used and that no side effects affecting the observable behavior of<br class="">the program are produced.</blockquote></div><div class=""><br class=""></div><div class=""><br class=""><div apple-content-edited="true" class="">David Barto<br class=""><a href="mailto:barto@cambridgesemantics.com" class="">barto@cambridgesemantics.com</a><br class=""><br class="">Sometimes, my best code does nothing. Most of the rest of it has bugs.<br class=""><br class=""><br class=""></div><br class=""></div></body></html>