Subject: Re: Bug with beta-16, floating point, and the optimizer
From: [email-masked] (Geoffrey Noer)

22 Apr 1997 18:15:04 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Content-Type: text
Original-To: [email-masked] (Jeff Deifik)
Original-Cc: [email-masked]
In-Reply-To: <[email-masked]> from "Jeff Deifik" at Nov 6, 96 05:24:03 pm
X-Mailer: ELM [version 2.4 PL23]
Original-Sender: [email-masked]

Your test case works fine under upcoming beta 18...

-- 
Geoffrey Noer
[email-masked]

> The small, attached program demonstrates a bug with beta-16 gcc.
> If the optimizer is set to '-O' the program executes correctly.
> If the optimizer is set to '-O2' or '-O3' the program generates an
> exception.
>
>         Jeff Deifik     [email-masked]      [email-masked]
> 
> /* y.c, demonstrates a bug with gnu-w32 beta 16 and the optimizer... */
> /*
> To produce an exception say:
>    gcc -O2 -g -c y.c -o y.o
>    gcc y.o -lm -o yyy.exe
>    yyy
> 
> To produce no exception say:
>    gcc -O -g -c y.c -o y.o
>    gcc y.o -lm -o yyy.exe
>    yyy
> 
> */
> /* Written 11/06/96 by Jeff Deifik	*/
> 
> #include	<stdio.h>
> #include	<math.h>
> 
> typedef enum { False = 0, True = 1 } Boolean;
> 
> float FLOAT_TO_ROUNDED_FLOAT(float);
> int flo_close(double value,double f,double clo);
> 
> int main(int argc, char *argv[])
> {
> Boolean	fail = False;
> double	d;
> float	f;
> 
>     d = rint(47);
>     if (!flo_close(47.0f,d,0.0001f))
>       { (void)printf("47 %f\n",d); fail = True; }
> 
>     f = FLOAT_TO_ROUNDED_FLOAT(47.0);
>     if (!flo_close(47.0f,f,0.0001f))
>       { (void)printf("47 %f\n",f); fail = True; }
> 
>     return 1;
> }
> 
> /* Value is the ideal number, f is what it really is.*/
> int	flo_close(double value,double f,double clo)
> {
>     return(((f+clo) >= value) && ((f-clo) <= value));
> }
> 
> float	FLOAT_TO_ROUNDED_FLOAT(float x)		{ return(floor(x+0.5)); }

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".