Go to the first, previous, next, last section, table of contents.


Floating-point Exception Handling

The gcc backend and, consequently, g77, currently provides no 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 inherited from the system-dependent startup code.

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>
void __attribute__ ((constructor))
trapfpe () {
  (void) __setfpucw (_FPU_DEFAULT &
                     ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM));
}


Go to the first, previous, next, last section, table of contents.