SUMMARY: "Floating exception" and GCC

From: Erik Nolf <nolf_at_petaxp.rug.ac.be>
Date: Wed, 29 Apr 1998 11:57:18 +0200

Hello Managers,


PROBLEM:
-------

I have a small problem concerning DEC Alpha's "Floating exception" and
the GNU C compiler. I prefer to use the GCC compiler for portability
to other machines and Unixes. Some other Unixes handle `denorms, NaNs
and infinities' by default and so does my code compiled with GCC.
However, on our DEC Alpha machine this is not the default procedure
and the use of any bad float results in a core dump. Nice but ugly!

We read raw images of type float: using the wrong endian, our
program dumps a core. Ofcourse, I would like to prevent this.

In fact, most users on our Alpha complain about this and now I am
looking for a solution to give. (because I like this machine a lot!)

The `cc` compiler provides the option `-ieee_with_inexact' but what
about the GCC compiler?

I looked for some options or little code and did find some "possible
solutions". Now I would be glad to read some advice of someone who
knows more about this.


QUESTION:
--------

How can I prevent the core dump in case of a "Floating exception" with GCC?



SUMMARY:
-------

A) The main solution

I got this solution from `Imran Haq' who mailed a similar question to the
newsgroup `news:gnu.gcc.help'

The recent GNU C Compiler 2.8.x has an option `-mieee' which handles
the "Floating exceptions" on a DEC Alpha system. The related options
are documented in the info-pages, but not in the GCC man-page.

A small program succeeded. My large project however core dumped while
compiling (segmentation fault, Not enough memory, etc ...)! This is
too ugly! Without the option it compiles like it used to do.

Because I am not a professional programmer and we do use and ancient
operating system (OSF/1 3.0) I'll leave the option for what it 's
worth until further notice, OS upgrade and/or improvements ...


If you like to experiment, here are some hexcodes (little endian):

float Signaling Nan : 0x3c86bcff (bad)
float Pos Denormalized: 0x3b043400 (bad)

float Pos Zero : 0x00000000
float Neg Zero : 0x00000080


B) Personnal

The math-library has some functions 'fp_class()' and 'fp_classf()' to
detect the double/float types "Nan, Denormalized, Zero, Infinity and
Normalized". A simple if( ) could prevent the use of the bad float
values ...


C) Nice to know

>From "Jean Schuller" I received this tip (the only reply from the list):

"I don't know if I understand your problem but you can
avoid core files using "limit coredumpsize 0"
in .cshrc."




My sincere thanks to those people who replied.



Greetings,


        Erik-II


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Erik Nolf email: Erik.Nolf_at_rug.ac.be
RUG-ELIS (MEDISIP) tel : +32-9-264.66.28
Proeftuinstraat 86 fax : +32-9-264.66.99
B-9000 Gent, Belgium www : http://petaxp.rug.ac.be/~nolf
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Received on Wed Apr 29 1998 - 12:01:53 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:37 NZDT