From: jdeifik AT weasel DOT com (Jeff Deifik) Subject: Bug with beta-16, floating point, and the optimizer 6 Nov 1996 19:22:15 -0800 Sender: daemon AT cygnus DOT com Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <2.2.32.19961107012403.00e21c24.cygnus.gnu-win32@pop.ni.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=====================_847358643==_" X-Sender: jdeifik AT pop DOT ni DOT net X-Mailer: Windows Eudora Pro Version 2.2 (32) Original-To: gnu-win32 AT cygnus DOT com X-Attachments: D:\j\lib\y.c; Original-Sender: owner-gnu-win32 AT cygnus DOT com --=====================_847358643==_ Content-Type: text/plain; charset="us-ascii" 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. This is on a pentium 120, running windows nt-4.0 server, with service patch 1. I have a fresh install of beta-16, with no old files lingering around. I have specified gcc_exec_prefix, and I have a /tmp directory... Jeff Deifik jdeifik AT weasel DOT com turbo AT weasel DOT com --=====================_847358643==_ Content-Type: text/plain; charset="us-ascii" /* 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 #include 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)); } --=====================_847358643==_-- - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".