code optimizations and numerical research

Ian Lance Taylor ian@airs.com
Mon May 16 16:39:00 GMT 2005


p@dirac.org (Peter Jay Salzman) writes:

> Just to make sure --- so you're saying that even though I'm enabling SIGFPE
> to catch exceptions:

...

> all the talk about -ffast-math making the compiler assume that args and
> results of math operations are correct and finite has no bearing on either
> my code (which certainly doesn't do what you described above) or my enabling
> and catching FPE exceptions?

Obviously it's hard to be completely sure whether your code is going
to be OK.  But -ffast-math won't make SIGFPE signals go away.  It just
means, more or less, that the compiler will assume they won't happen.
If you don't try to resume execution of the failing operation after
receiving a SIGFPE error--if you just give an error or something--then
you should be fine.

In fact, enabling the SIGFPE signal as you do will probably make you
safer when using -ffast-math.  For example, -ffast-math may not handle
floating point infinities correctly, but you've asked for a signal
when an infinity is generated anyhow, so your code will presumably
never see one.

Ian



More information about the Gcc-help mailing list