home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.compilers      Compiler construction, theory, etc. (Mod      2,753 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 2,243 of 2,753   
   christian.bau@cbau.wanadoo.co.uk to Steven G. Kargl   
   Re: Compiler optimization and floating p   
   28 Oct 13 15:54:46   
   
   On Thursday, October 24, 2013 5:38:13 PM UTC+1, Steven G. Kargl wrote:   
   > #include    
   > int   
   > main(void)   
   > {   
   >    float a, b;   
   >    a = 0.;   
   >    b = a / a;   
   >    if (a + b != b + a) printf("fubar\n");   
   >    return (0);   
   > }   
   >   
   > Can an optimizing compiler eliminate the if-statement?   
      
   It can eliminate the test because it will always be true (on IEEE   
   implementations where 0.0 / 0.0 is NaN).  It cannot eliminate the   
   if-statement because printf () should be called.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca