This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug math/17885] New: powerpc: fesetexceptflag not correct setting the new flag
- From: "azanella at linux dot vnet.ibm.com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Tue, 27 Jan 2015 12:35:35 +0000
- Subject: [Bug math/17885] New: powerpc: fesetexceptflag not correct setting the new flag
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=17885
Bug ID: 17885
Summary: powerpc: fesetexceptflag not correct setting the new
flag
Product: glibc
Version: 2.20
Status: NEW
Severity: normal
Priority: P2
Component: math
Assignee: unassigned at sourceware dot org
Reporter: azanella at linux dot vnet.ibm.com
The following testcase:
#include <stdio.h>
#include <fenv.h>
void
show_fe_exceptions (void)
{
printf ("current exceptions raised: ");
if (fetestexcept (FE_DIVBYZERO))
printf (" FE_DIVBYZERO");
if (fetestexcept (FE_INEXACT))
printf (" FE_INEXACT");
if (fetestexcept (FE_INVALID))
printf (" FE_INVALID");
if (fetestexcept (FE_OVERFLOW))
printf (" FE_OVERFLOW");
if (fetestexcept (FE_UNDERFLOW))
printf (" FE_UNDERFLOW");
if (fetestexcept (FE_ALL_EXCEPT) == 0)
printf (" none");
printf ("\n");
}
int
main (void)
{
fexcept_t excepts;
/* Setup a "current" set of exception flags. */
feraiseexcept (FE_INVALID);
show_fe_exceptions ();
/* Save current exception flags. */
fegetexceptflag (&excepts, FE_ALL_EXCEPT);
/* Temporarily raise two other exceptions. */
feclearexcept (FE_ALL_EXCEPT);
feraiseexcept (FE_OVERFLOW | FE_INEXACT);
show_fe_exceptions ();
/* Restore previous exception flags. */
fesetexceptflag (&excepts, FE_ALL_EXCEPT);
show_fe_exceptions ();
return 0;
}
Fails on powerpc{32,64}-fpu:
$ gcc test.c -o test -lm
$ ./testrun.sh ./test
current exceptions raised: FE_INVALID
current exceptions raised: FE_INEXACT FE_OVERFLOW
current exceptions raised: FE_INEXACT FE_INVALID FE_OVERFLOW
The expected result is:
$ ./test
current exceptions raised: FE_INVALID
current exceptions raised: FE_INEXACT FE_OVERFLOW
current exceptions raised: FE_INVALID
This is due a typo in commit 18f2945ae9216cfcd53a162080a73e3d719de9e6, which
sets the new flag using the old value. The trivial patch fixes it:
diff --git a/sysdeps/powerpc/fpu/fsetexcptflg.c
b/sysdeps/powerpc/fpu/fsetexcptflg.c
index 5d99bf2..836d839 100644
--- a/sysdeps/powerpc/fpu/fsetexcptflg.c
+++ b/sysdeps/powerpc/fpu/fsetexcptflg.c
@@ -40,7 +40,7 @@ __fesetexceptflag (const fexcept_t *flagp, int excepts)
This may cause floating-point exceptions if the restored state
requests it. */
if (n.l != u.l)
- fesetenv_register (u.fenv);
+ fesetenv_register (n.fenv);
/* Deal with FE_INVALID_SOFTWARE not being implemented on some chips. */
if (flag & FE_INVALID)
--
You are receiving this mail because:
You are on the CC list for the bug.