wlp@calmasd.Prime.COM (Walter L. Peterson, Jr.) (02/07/89)
I have recently encountered an odd situation with the Turbo-C V2.0 Integrated Debugger. I am in the process of making some modifications to some neural net software (Rumelhart & McClelland's PDP book & disks) and I'm compiling it with Turbo-C V2.0. Everything compiles and links OK, but when I run the EXE from the DOS prompt I get the error: Floating Point Error: Domain This occurs soon after the program starts computing the weights in the network, but I'm not certain exactly where ( the software is extensive, and is loaded with floating point computations ). The upshot of all of this is that, in order to find the floating point error, I tried running it in the integrated debugger. Well, Murphy's Law was in effect and so naturally it WORKED! I have tried repeatedly to get the silly thing to fail while in the debugger ( or just running out of the integrated environment at all for that matter ) and it runs perfectly. ( I have checked the results against an unmodified version and the results ARE correct, too ). EVERY time I run the program from the DOS prompt, it fails with the same floating point error at ( apparently ) the same place; EVERY time I run the program from the Turbo-C environment, it works !! While I have seen similar situations with VAX/VMS and occasionally on UNIX ( that is, something that fails when run normally, but works in the debugger ), this is the first time I have seen it in Turbo-C. Has anyone out there ever encountered this type of situation with the Turbo-C environment and if so is there a solution ? -- Walt Peterson. Prime - Calma San Diego R&D (Object and Data Management Group) "The opinions expressed here are my own and do not necessarily reflect those Prime, Calma nor anyone else. ...{ucbvax|decvax}!sdcsvax!calmasd!wlp
bright@Data-IO.COM (Walter Bright) (02/09/89)
In article <210@calmasd.Prime.COM> wlp@calmasd.Prime.COM (Walter L. Peterson, Jr.) writes:
<EVERY time I run the program from
<the DOS prompt, it fails with the same floating point error at
<( apparently ) the same place; EVERY time I run the program from the
<Turbo-C environment, it works !!
<Has anyone out there ever encountered this type of situation with the
<Turbo-C environment and if so is there a solution ?
This is the classic problem with using a debugger. Possible reasons are:
1. Using an uninitialized variable. The debugger loads the program into
a different location in memory, resulting in a different initial value.
2. The debugger uses some memory, meaning that the storage layout of your
program is now different. Pointer bugs will therefore have different
effects.
3. The debugger uses some memory, which will cause a program to run out
of free store sooner, with correspondingly different behavior.
4. The debugger may trap floating point and emulate it itself, and have
bugs in it causing different behavior.
Solution? Debug using gedanken experiments and printf's. Run a fresh
listing and read it during lunch.
raymond@ptolemy.arc.nasa.gov (Eric A. Raymond) (02/09/89)
In article <210@calmasd.Prime.COM> wlp@calmasd.Prime.COM (Walter L. Peterson, Jr.) writes: > Floating Point Error: Domain > It seems like you may be passing a float when a double was expected. One sneaky way for this to occur is if you use new function prototypes in one source file and old style declarations in another file. For example: File A: extern void foo(float x); File B: void foo(x) float x; { ... } In File A, foo is defined as you would expect (x is a float). In file B, x is promoted to a double. ---- -- Eric A. Raymond (raymond@pluto.arc.nasa.gov) Nothing left to do but :-) :-) :-)