From: dahms AT ifk20 DOT mach DOT uni-karlsruhe DOT de Subject: Re: Maths ruined when optimizing in gcc 26 Nov 1996 14:45:12 -0800 Sender: daemon AT cygnus DOT com Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <009ABF70.EA7639E0.5267.cygnus.gnu-win32@ifk20.mach.uni-karlsruhe.de> Original-To: khan AT xraylith DOT wisc DOT edu Original-CC: gnu-win32 AT cygnus DOT com, dahms AT ifk20 DOT mach DOT uni-karlsruhe DOT de Original-Sender: owner-gnu-win32 AT cygnus DOT com Hi Mumit, you wrote: : Another data point here. I'm in the process of testing g77 port to : cygwin32 (it was quite simple once I figured out the right flags to : libfI77) and the big gotcha is the every time I use -O, some of the : programs produce NaNs all over the place! Haven't been able to pin : point where it happens yet, but hopefully soon. : : Anybody have a short program that screws up the numerics with -O? If : so, please email it me (if fortran, then either original or f2c'd will : do fine). Yes, here it is: --- snip here --- #include int main(argc, argv) int argc; char *argv[]; { volatile char c = 10; volatile int i = c; float x = c / 5.0, y = i / 5.0; printf("%.2f %.2f\n", x, y); return 0; } --- snip here --- with the following results: --- snip here --- bash$ gcc floatbug.c -o floatbug.exe bash$ floatbug 2.00 2.00 bash$ gcc -O floatbug.c -o floatbug.exe bash$ floatbug Inf Inf bash$ --- snip here --- This is stripped down from my big program which also produced NaNs. The original doesn't use volatile, but that prevents compile time evaluation. Astonishingly this shows Inf (using b16), which is not any better! BTW, I just joined the mailinglist, so I missed the start of the thread. Bye, Heribert (dahms AT ifk20 DOT mach DOT uni-karlsruhe DOT de) - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".