<div dir="ltr"><font face="arial, helvetica, sans-serif">Why the output is different for this below program when compiled using clang with fast-math optimization</font><div><font face="arial, helvetica, sans-serif"><br></font></div><div>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(195,55,32)"><font face="arial, helvetica, sans-serif"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures;color:rgb(213,59,211)">#include</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures"><stdio.h></span></font></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0);min-height:21px"><font face="arial, helvetica, sans-serif"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures"></span><br></font></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><font face="arial, helvetica, sans-serif"><span class="gmail-s3" style="font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">int</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures"> main() {</span></font></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><font face="arial, helvetica, sans-serif"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span></span><span class="gmail-s3" style="font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">double</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures"> d = </span><span class="gmail-s4" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">1.0</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures">;</span></font></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><font face="arial, helvetica, sans-serif"><span class="gmail-s5" style="text-decoration-line:underline;font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span></span><span class="gmail-s6" style="text-decoration-line:underline;font-variant-ligatures:no-common-ligatures;color:rgb(52,188,38)">double</span><span class="gmail-s5" style="text-decoration-line:underline;font-variant-ligatures:no-common-ligatures"> max = </span><span class="gmail-s7" style="text-decoration-line:underline;font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">1.79769e+308</span><span class="gmail-s5" style="text-decoration-line:underline;font-variant-ligatures:no-common-ligatures">; <span class="gmail-Apple-converted-space"> </span></span></font></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif"><span class="gmail-Apple-converted-space"> </span>d /= max;</font></span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><font face="arial, helvetica, sans-serif"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>printf(</span><span class="gmail-s4" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">"d:</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures;color:rgb(213,59,211)">%e</span><span class="gmail-s4" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">:</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures;color:rgb(213,59,211)">\n</span><span class="gmail-s4" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">"</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures">, d);</span></font></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif"><span class="gmail-Apple-converted-space"> </span>d *= max;</font></span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><font face="arial, helvetica, sans-serif"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>printf(</span><span class="gmail-s4" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">"d:</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures;color:rgb(213,59,211)">%e</span><span class="gmail-s4" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">:</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures;color:rgb(213,59,211)">\n</span><span class="gmail-s4" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">"</span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures">, d);</span></font></p>
<p class="gmail-p4" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(205,121,35)"><font face="arial, helvetica, sans-serif"><span class="gmail-s8" style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"><span class="gmail-Apple-converted-space"> </span></span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures">return</span><span class="gmail-s8" style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> </span><span class="gmail-s4" style="font-variant-ligatures:no-common-ligatures;color:rgb(195,55,32)">0</span><span class="gmail-s8" style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">;</span></font></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif">}</font></span></p><p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif"><br></font></span></p><p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font face="arial, helvetica, sans-serif" style="">prints 0 with fast math but 1 without fast math.</font></span></p></div></div>