home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!cs.utexas.edu!natinst.com!banshee
- From: banshee@natinst.com (Jeff Kellam)
- Subject: Possible Borland 3.1 bug
- Message-ID: <1992Aug20.165327.18694@natinst.com>
- Sender: news@natinst.com
- Nntp-Posting-Host: eagle.natinst.com
- Organization: National Instruments, Austin, TX
- Date: Thu, 20 Aug 1992 16:53:27 GMT
- Lines: 48
-
- There appears to be a bug in the optimization routines of
- the Borland 3.1 compiler.
-
-
- If the code below is compiled with optimization set to fastest code
- a floating point error occurs.
-
- Using the debugger, I was able to determine that the source of the
- problem is related to the optimization of -divisor, which is calculated
- outside of the loop. It seems in calculating the value of -divisor,
- the compiler doesn't clean up the floating point stack, so after eight
- iteration of Function, the FP stack overflows.
-
- If anyone sees a flaw in this reasoning, or has had similiar experiences,
- please post or email me at banshee@natinst.com
-
-
- Thanks,
-
- Jeff Kellam
- banshee@natinst.com
-
-
- /* PROGRAM STARTS */
-
- double array[5] = {1.0,2.0,3.0,4.0,5.0};
-
- void Function(double);
-
- main() {
- int i;
-
- for (i=10; i<20; i++)
- Function(i);
- return 0;
- }
-
- void Function(double divisor) {
-
- int i;
-
- for (i=0;i<5;i++) {
- array[i] *= divisor;
- array[i] *= -divisor;
- }
- }
-
- /* PROGRAM ENDS */
-