<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">On Fri, Apr 5, 2013 at 6:49 PM, Joe Groff </span><span dir="ltr" style="font-family:arial,sans-serif;font-size:13px"><<a href="mailto:arcata@gmail.com" target="_blank">arcata@gmail.com</a>></span><span style="font-family:arial,sans-serif;font-size:13px"> wrote:</span><br style="font-family:arial,sans-serif;font-size:13px">
<div class="gmail_quote" style="font-family:arial,sans-serif;font-size:13px">...<div class="im"><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">The platform is irrelevant; division by zero is undefined, and compilers are allowed to optimize as if it can't happen. </div></div></div></blockquote><div>
 </div></div><div>Understood.</div><div><span style="color:rgb(136,136,136)"><br></span></div><div>I don't mean to nag, but I'm not arguing which is [more] correct: the Standards or the platform. Both have their own merits. At least to me they both have merits. The choice should be up to the compiler implementor. And, I would like to see LLVM make that choice easy for the compiler implementor. Maybe an anachronism, but there is some history of this option being built-in to other major compilers: GNU, Sun, HP, IBM, SGI, Compaq, etc.</div>
<div><br></div><div>But, if others can not (or will not) benefit from this option, I will not force my individual needs on the whole.</div><div><br></div><div><div class="im"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Both gcc and clang will lift the division out of this loop, for example, causing the hardware trap to happen in the "wrong" place if bar is passed zero:</div>
<div><br></div><div>void foo(int x, int y);</div><div><br></div><div>void bar(int x) {</div><div><span style="white-space:pre-wrap">  </span>for (int i = 0; i < 100; ++i) {</div><div><span style="white-space:pre-wrap">               </span>foo(i, 200/x);</div>
<div><span style="white-space:pre-wrap">  </span>}</div><div>}</div></div></div></div></blockquote><div><br></div></div><div>I'm less concerned about "where" the trap happens as I am about "if" it happens. For example, a Fortran program with division-by-zero is, by the Standard, non-conforming. Pragmatically, not a Fortran program. Rather than wrong answers, I would like to see a hard error indicating that a program is non-conforming to the Standard.</div>
<div class=""><div id=":168" class="" tabindex="0"><img class="" src="https://mail.google.com/mail/u/1/images/cleardot.gif" style=""></div></div></div><span class=""><font color="#888888">-Cameron</font></span></div><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div><br></div></div>