HUGE

Sam Fulcomer sgf at cs.brown.edu
Fri Jan 18 06:38:49 AEST 1991


In article <72495 at bu.edu.bu.edu> tjh at bu-pub.bu.edu (Tim Hall) writes:
>The following code demonstrates my problem.....
>
>#define NOVALUE ((float)(HUGE * 0.001))
>        float a;
>
>        a = NOVALUE;
>        printf( "%f %f\n", NOVALUE, a ); /* They look exactly the same! */
>        if ( a == NOVALUE )              /* But noooooooooooooooooooooo */


Ayuh, well, it should work. The bug is in the new optimization code in the 
compiler (even at optimization O0).

It used to be that the NOVALUE macro would be faithfully inserted in the 
code (ie, the resulting program would execute the whole works with each
incidence of the macro). The compiler was changed to pre-calculate NOVALUE
and just insert the value in the code (drops out a lot of instructions).

The problem occurs in the way the compiler handles the if statement.
Instead of doing an li.s followed by a cvt.d.s for the insertion of NOVALUE
it does a li.d, thus doing a double compare between a single and a double.
Of course they're not equal at that point, but they should be...

Of course, this is all sheer speculation, but it sounds like a bug...

_/**/Sam



More information about the Comp.sys.sgi mailing list