<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 6, 2014 at 12:52 PM, Stephen Canon <span dir="ltr"><<a href="mailto:scanon@apple.com" target="_blank">scanon@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>This appears to have nothing to do with signbit, but rather that we are somehow “optimizing” –NaN —> NaN.</div>
<div><br></div><div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="color:#35568a">int</span> main(<span style="color:#35568a">int</span> argc, <span style="color:#35568a">char</span> *argv[]) {</div>
<div style="margin:0px;font-size:11px;font-family:Menlo">    <span style="color:#35568a">double</span> x = -__builtin_nan(<span style="color:#e82300">""</span>);</div><div style="margin:0px;font-size:11px;font-family:Menlo">
    printf(<span style="color:#e82300">"%d\t%d\n"</span>, signbit(x));</div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(53,86,138)"><span style="color:#000000">    </span>return<span style="color:#000000"> </span>0<span style="color:#000000">;</span></div>
<div style="margin:0px;font-size:11px;font-family:Menlo">}</div></div><div style="margin:0px;font-size:11px;font-family:Menlo"><br></div>this prints zero on recent clang (should print 1).  Stepping through, x is being set to a positive NaN.</blockquote>
</div><br>The standards for C and C++, and consequentially Clang and LLVM, are terribly underspecified w.r.t. things like NaN behavior. =/ We have seen this before, and even if we fix it in Clang/LLVM I worry that it will regress as there are many places where we model NaNs in a manner slightly too aggressive to be strictly IEEE-754 conforming. =[</div>
</div>