GCC Bugzilla – Bug 29887
wrong-code for errno handling on overflow/underflow
Last modified: 2007-01-22 17:03:07 UTC
builtins.c:expand_errno_check() can only handle setting EDOM if the operation
returns NaN on error. Most overflow/underflow conditions result in -Inf/+Inf
instead and with non-default rounding-mode (-frounding-math) the maximum or
minimum floating-point value will be returned (round to -Inf/+Inf or zero).
int main(int argc, char **argv)
double y = atof(argv);
double x = exp (y);
printf("%.6e %.6e\n", y, x);
which shall print "errno: Numerical result out of range" if you pass 5000
to the testcase executable but prints "errno: Success" if you build with
-funsafe-math-optimizations on i686 which will do an inline expansion for
I don't understand completely what you mean. Is the problem in the builtin exp() ? Should it check its argument for large numbers?
The problem is that we believe we can handle all errno checking/setting via
the expand_errno_check() routine which is not true for overflow/underflow but
only for invalid arguments that result in a NaN.
(In reply to comment #2)
> The problem is that we believe we can handle all errno checking/setting via
> the expand_errno_check() routine which is not true for overflow/underflow but
> only for invalid arguments that result in a NaN.
Is there underflow/overflow if the value is so small/big that we end up with zero/infinite? I am really confused about that. See for example bug 23572.
With overflow we end up with Inf or -Inf, with underflow we end up with 0. (or even -0.?) - but underflow doesn't seem to require a diagnostic errno setting.
I don't see how this relates to PR23572 though.