Subject: floating point optimization bug, beta version 16 of GCC
From: [email-masked] ("David C. Feldmeier")

19 Oct 1996 13:46:52 -0700
Sender: [email-masked]
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Sender: [email-masked]
X-Mailer: Windows Eudora Light Version 1.5.4 (32)
Original-To: [email-masked]
Original-Cc: [email-masked]
Original-Sender: [email-masked]

I have been using your GCC for several months now, and I've generally had
good luck with it.  However, I seems to have found an optimizer bug.  Here
is some code that shows the bug:

?* START OF CODE */
#
/* bug.c
 *
 * David C. Feldmeier
 * October 19, 1996
 *
 */

#include <stdio.h>
#include <stdlib.h>

static void func_B(
unsigned long redundancy) { /* percentage of redundancy to use */
  printf ("inv redund %f, test %f\n", 100.0/(double)redundancy,
	  100.0/(double)300L);
}

int main() {
  unsigned long redundancy = 300L;
  func_B(redundancy);
}
/* END OF CODE */

Here is the list of commands given to bash:

bash$ gcc -o bug.exe bug.c
bash$ bug
inv redund 0.333333, test 0.333333
bash$ gcc -O1 -o bug.exe bug.c
bash$ bug
inv redund 0.000000, test 0.333333
bash$

As you can see, when the optimizer is running, it the code generates an
incorrect floating point result.

The code which generates this bug is no different than code that I ran
sucessfully using a previous version (13, I believe) of GCC.  Also, this bug
may be related to a floating point problem reported by Peter Fan to the
mailing list on April 30, 1996.

I am running the lastest version of the GCC compiler, beta release 16.  My
computer is a 133 MHz Pentium Micron Millenia with 16M RAM.  I am running
GCC using the DOS emulator under Windows95.  If you need any other
information, please let me know.  Thanks.

                                                        -Dave

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