Copyright (C) 2000-2012 |
GNU Info (g77-295.info)Floating-point Exception HandlingFloating-point Exception Handling --------------------------------- The `gcc' backend and, consequently, `g77', currently provides no general control over whether or not floating-point exceptions are trapped or ignored. (Ignoring them typically results in NaN values being propagated in systems that conform to IEEE 754.) The behaviour is normally inherited from the system-dependent startup code, though some targets, such as the Alpha, have code generation options which change the behaviour. Most systems provide some C-callable mechanism to change this; this can be invoked at startup using `gcc''s `constructor' attribute. For example, just compiling and linking the following C code with your program will turn on exception trapping for the "common" exceptions on an x86-based GNU system: #include <fpu_control.h> static void __attribute__ ((constructor)) trapfpe () { fpu_control_t cw = _FPU_DEFAULT & ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM); _FPU_SETCW(cw); } A convenient trick is to compile this something like: gcc -o libtrapfpe.a trapfpe.c and then use it by adding `-trapfpe' to the `g77' command line when linking. automatically generated by info2www version 1.2.2.9 |