This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

FP exception handling


Subject:
        Floating exceptions in G77 on WIN95

I sent the following Email in March . Please advise if there has been
any progress in providing a FP exception handler.


I am using  :-

g77 version 2.95.2 19991024 (release) (from FSF-g77 version 0.5.25
19991024 (rel
ease))
Driving: C:\GCC-29~1.2\BIN\G77.EXE -v -c -xf77-version /dev/null -xnone
G77.EXE: /dev/null: No such file or directory
Reading specs from
C:\GCC-29~1.2\BIN\..\lib\gcc-lib\i386-mingw32\2.95.2\specs
gcc version 2.95.2 19991024 (release)

Microsoft Windows 95  4.00.950 C  IE 5 5.00.2314.1003

Fortran options :-
g77  -fexceptions -fhandle-exceptions -fugly-init -mno-align-double -c
-g -w -fvxt -fno-automatic



I am putting together a fairly large engineering program but I keep on
encountering  Floating Point exceptions which
result in print-outs similar to this:-

     9    9  $$ LOCN HOLES DRILL NOW FEEDS OUT OF HOLES  (WAS RAPID)
    10   10  L1 =LINE/20,30,200,100
     L1 (   0 )    LINE  4    -1.#IND00    -1.#IND00     0.000000
-1.#IND00
    11   11  C1=C/20,30,200
     C1 (   0 )  CIRCLE  7    20.000000    30.000000     0.000000
0.000000     0.000000     1.000000
200.000000

    12   12  PSIS/0,0,1,20
 NESTED (   0 )   PLANE  4     0.000000     0.000000     1.000000
20.000000
    13   13  FROM/200,200,100
    14   14  GO/C1
    15   15  PRINT/3,ALL
     L1 (   0 )    LINE   4    -1.#IND00    -1.#IND00     0.000000
-1.#IND00
     C1 (   0 )  CIRCLE   7    20.000000    30.000000     0.000000
0.000000     0.000000     1.000000
200.000000



I have read the documentation from g77_20.htm   viz :--

" Floating-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 ()
{
  __setfpucw (_FPU_DEFAULT &
              ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM));
}

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.  "


HOWEVER  I do not have either fpu_control.h  or _setfpucw in my
libraries.


Can you please advise me how to avoid handle FP exceptions.


                                    Ian Hacking , Lancaster, England





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]