Path: utzoo!censor!geac!torsqnt!hybrid!scifi!bywater!uunet!brunix!sgf From: sgf@cs.brown.edu (Sam Fulcomer) Newsgroups: comp.sys.sgi Subject: Re: HUGE Message-ID: <61821@brunix.UUCP> Date: 17 Jan 91 19:38:49 GMT References: <72495@bu.edu.bu.edu> Sender: news@brunix.UUCP Reply-To: sgf@cs.brown.edu (Sam Fulcomer) Organization: Brown University Department of Computer Science Lines: 27 In article <72495@bu.edu.bu.edu> tjh@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