Xref: utzoo comp.lang.c:39548 comp.os.msdos.programmer:5298 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!basfpac!stratsft!dwayne From: dwayne@stratsft.uucp (Dwayne Bailey) Newsgroups: comp.lang.c,comp.os.msdos.programmer Subject: Turbo C Floating Point bug? Message-ID: <1991May24.021331.3949@stratsft.uucp> Date: 24 May 91 02:13:31 GMT Organization: Strategic Software, Allen Park, MI Lines: 48 A client of mine is having a problem with Turbo C 2.0, which I think is a bug in the compiler, but I'm not positive. Any light anyone can shed would be greatly appreciated! Here is a code fragment which produces the problem: /* A bunch of static data defined here */ static struct stuff={...}; main() { float dummy = 2300.0; dummy = dummy / 100000.0; exit(0); } Simple enough, right? Well, if it were just this code, it would be. However, my client is linking in some third party libraries (Window BOSS and Greenleaf COMM libraries, both compiled for TC.) The source file which defines main() also defines some fairly large initialized static data. What happens is that the compiler also places the 100000.0 in a static variable which gets used at runtime. Unfortunately, at runtime the value placed in the code points at some other data element, not the expected number. The result is random answers or, in this case, Floating point overflow error! I think the problem is in the code Borland uses to fix up the floating point routines, based on the presence or absence of the 8087 (both cause the same problem.) FYI, I also linked without the windows & comm libraries. Since I don't call any of those routines before the error crops up, the unresolved externals should not be a problem. Same result, so I don't think you can blame it on something wierd in the third party stuff. Also, Turbo C++ 2.0 seems to work fine on the same code. Any help would be greatly appreciated. Dwayne Bailey ======================================================================== ..!uunet!basfpac!stratsft!dwayne Dwayne Bailey + Strategic Software is ME, so my opinions ARE those Strategic Software + of my company! ======================================================================== -- ======================================================================== ..!uunet!basfpac!stratsft!dwayne Dwayne Bailey + Strategic Software is ME, so my opinions ARE those