Copyright (C) 2000-2012 |
GNU Info (g77-300.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 a GNU system using glibc 2.2 or newer: #define _GNU_SOURCE 1 #include <fenv.h> static void __attribute__ ((constructor)) trapfpe () { /* Enable some exceptions. At startup all exceptions are masked. */ feenableexcept (FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW); } 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 |