On Tue, Feb 05, 2002 at 10:54:42PM +0800, Zhang Fuxin wrote: > hi, > It seems gcc with optimization > -O2 will produce incorrect code for fp code: > I find this example when tracking down the libm-test failures. > ( expf(NaN) == NaN will report an extra "invalid operation" exception ) > The faulting code snippet is: > float __my_expf(float x) /* wrapper expf */ > { > float z; > unsigned int hx; > z = __ieee754_expf(x); > if(_LIB_VERSION == _IEEE_) return z; > if(__finitef(x)) { > if(x>o_threshold) > return 1.0; > else if(x<u_threshold) > return 2.0; > printf("haha\n"); > } > return z; > } > > with -O2(or higher),some statements inside "if (__finitef(x))" are put before > testing the return value of __finitef(x),one of which is a c.lt.s that cause > the extra "invalid operation" exception being raised. > This bug seem fixed in gcc 3.1. H.J.