This is the mail archive of the
mailing list for the GCC project.
Re: [RFC Patch]: Implement remainder() as built-in function [PR fortran/24518]
On 10/24/06, Roger Sayle <email@example.com> wrote:
All the other bits look reasonable. But it might be nice if we changed
the errno handling to check whether y is zero ourselves before performing
the operation, rather than test for NaN afterwards. This should be
faster, and may even be able to be optimized away during the RTL
NaNs and errno are also returned in a couple of other situations. My
documentation says that:
When y is 0, remainder() returns NaN. and sets errno to
If the value of x is +Inf, remainder() returns NaN and sets
errno to EDOM.
If x or y is NaN, then the function returns NaN.
(errno is not set to EDOM in the last case). From this, there is no
other way than to treat NaN as abnormal return value from intrinsic,
and when NaN is detected, further actions (including setting errno)
depend on library implementation.
We should also think a little about Richard's suggestion of perhaps
being more aggresive about ignoring errno when the language standards
state that this isn't a strict requirement. However, that should
probably be a independent patch (perhaps with its own enhancement
PR?), maybe even a new command line option, -fstrict-errno-math?.
Perhaps Richard's problem is specific to lrint (). At least in
manpages (which are not considered as an authoritative
documentation...) it is stated that lrint() _may_ set errno to EDOM,
but i.e. remainder() sets errno to EDOM for y=0.
It should be noted that glibc does not set EDOM when remainder()
returns NaN, where solaris libm does.