i386/105: Distributed libm (msun) has non-standard error
bde at zeta.org.au
Thu Jan 8 01:30:19 PST 2004
The following reply was made to PR i386/105; it has been noted by GNATS.
From: Bruce Evans <bde at zeta.org.au>
To: Ryan Sommers <ryans at gamersimpact.com>
Cc: freebsd-gnats-submit at freebsd.org
Subject: Re: i386/105: Distributed libm (msun) has non-standard error handling.
Date: Thu, 8 Jan 2004 20:28:06 +1100 (EST)
On Wed, 7 Jan 2004, Ryan Sommers wrote:
> It looks like this problem has since been resolved. I believe this PR
> can be closed.
> ryans at lilshadow(~/src):cat test.c
> #include <stdio.h>
> #include <math.h>
> main ()
> printf ("acos = %g\n", acos (-2.0));
> printf ("pow = %g\n", pow(3, 1000001));
> ryans at lilshadow(~/src):gcc -lm -o test test.c
> ryans at lilshadow(~/src):./test
> acos = nan
> pow = inf
Many aspects of this are still open:
- adding "assert(errno == EDOM);" would show that error handling does not
conform to C90 (or the man page for at least the VAX and Tahoe cases;
the handing of domain errors for other cases seems to be undocumented
in the man pages).
- adding "#include <ieeefp.h> ... fpsetmask(fpgetmask() | FP_X_INV)"
would show that the oringal problem still exists, unless fpsetmask() is
permitted to break the operation of standard functions. Using
fpsetmask() gives undefined behaviour by taking the program out of C90
abd by fpsetmask()'s docmentation not being detailed enough to define
the behaviour. C99 defines the effect of the feset*() family on library
functions in detail. I don't completely understand this, and C99 avoids
the problem by not providing a way to unmask traps for FP exceptions.
This is mainly a documentation problem. Math functions should eventually
do the the following:
- not support C90 (they never did)
- conform to C99 with the <mumble> math extensions. Take the option to
never set errno for math functions.
- have a nonstandard fesetmask() function whose use breaks C99 conformance
in documented ways (should it affect math functions or only application
- conform to POSIX.1-2001. Set math_errhandling to MATH_ERREXCEPT to
indicate that setting errno is not done.
- document the above, and don't document VAX and Tahoe error handling.
- document "raise"ing of FP exceptions more clearly than POSIX (does it
call raise() or raise a SIGFPE? It had better not by default, but
fpsetmask() can certainly cause it to).
See also PR 56906.
More information about the freebsd-standards