This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: y0/y1/yn and exceptions - GCC 3.4 changes


On Fri, 19 Dec 2003, Andreas Jaeger wrote:
> I analyzed the y0 (0.0) failure for double:
>
> In e_j0.c we check for y0(0.0) with:
>         if((ix|lx)==0) return -one/zero;
>
> Previously GCC evaluated this at compiletime and generated a NaN but
> since this was done at compile-time, no exception was set at run-time
>
> Now GCC does the calculation at run-time and sets the exception
> (Roger, is this correct?  I remember you doing work in this area).
>
> What do you think?  Is GCC correct and we should change glibc?  In
> that case I'll make the changes to the math testsuite.

Hi Andreas,

Indeed the change was made to GCC to not evaluate floating point
division by zero in in-line code at compile-time, precisely to allow
the observable floating point exception to be raised if that division
ever gets executed.

The solution, given that this code is supposed to return a constant,
is to change the glibc source code such that the division is performed
in the initializer of a global or static variable.  In these cases, the
division by zero, and conversion into +-Inf or NaN is performed at
compile-time.  This is the idiom used by many of the testcases in
gcc.c-torture/execute/ieee that needs such non-finite values.

I hope this explains the current behaviour, and describes a sensible
work around.

Sorry for any inconvenience.

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


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