[PATCH] Set up errno properly for yn
Joseph S. Myers
joseph@codesourcery.com
Wed May 9 17:13:00 GMT 2012
On Wed, 9 May 2012, Marek Polacek wrote:
> This is a stab at fixing the bug 6808. The problem is that we weren't
> setting errno to ERANGE when the second argument is DBL_MIN/FLT_MIN.
> I had to use the fetestexcept function, since the FE_OVERFLOW _might_
> be set by the GET_HIGH_WORD(high,b) line in the __ieee754_yn function.
> I don't know whether this is The Right Thing To Do, it might be
> necessary to guard fetestexcept with feholdexcept/feupdateenv, but
> that seem quite expensive :/.
Arbitrary exceptions may be set before the function, and you don't want to
set errno based on a previous exception, only one raised during the
function.
> I've tried also
> if (isfinite (b) != 0)
> __set_errno (ERANGE);
> but that didn't work.
It should work if you fix the sense of the test ... (though for some
reason the usual idiom calls __finite, __finitef, __finitel directly).
I'd expect all versions of this function to need similar changes.
Conditioning the test on TEST_DOUBLE certainly seems wrong.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list