Dave’s simple additions to a TPL file to trap floating point errors
TOP_OF_MAIN_SECTION feenableexcept(FE_DIVBYZERO); // to trap division by zero GLOBALS_SECTION // the order of the include statements is important #include <fenv.h> // must appear before admodel.h #include <admodel.h>
Build the executable to use a debugger and run the program. When the program crashes, do a back trace (Status->Backtrace in DDD) to find the line in the .cpp file that caused the exception.
Warning: Jim reported some problems using fenv.h and discovered that it not available on some platforms. Apparently there are some unresolved portability problems and this function is missing on all non-glibc platforms: MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 11 2010-11, Cygwin 1.7.7, mingw, Interix 3.5, BeOS. See for more information.