Subject: standards/143358: nearbyint raises spurious
inexact exception



On Sun, Jan 31, 2010 at 02:20:30AM +1100, Bruce Evans wrote:
> On Sat, 30 Jan 2010 gavin@xxxxxxxxxxx wrote:
>
> >Synopsis: nearbyint raises spurious inexact exception
>
> >Note that a comment in the function itself in lib/msun/src/s_nearbyint.c
> >does also suggest that this PR is valid, "We save and restore the
> >floating-point environment to avoid raising an inexact exception." I've
> >also verified Solaris 10, Linux and FreeBSD 7.2 show the expected
> >behaviour.
>
> This seems to be a bug in gcc-4.2, or perhaps a bug in the inline asms.
> gcc-4.2 still works with -O0, but with -O it removes the entire fesetenv()
> in nearbyint(). The fegetenv() isn't removed though its result is never
> used. I didn't get anywhere good trying to fix this, but I got to the
> following worse place of interest: after replacing the fesetenv(&env) by
> fesetenv(&xenv) where xenv is an invalidly initialized global variable
> (all 0's), the fegetenv(&env) corrupted the current environment (looks
> a bit like xenv was used to initialize the current environment).
>
> Removing fesetenv() in other contexts would give larger bugs.

While looking at this, I tried to run the example on custom-build
gcc 4.4.3/binutils 2.20 toolchain, and bumped into the issue fixed
by
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/3eac7944b4112632ad6fb257c7ce31deda72d89f
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url :
http://lists.freebsd.org/pipermail/freebsd-standards/attachments/20100130/0179ff69/attachment.pgp



Privacy