public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/17885] New: powerpc: fesetexceptflag not correct setting the new flag
@ 2015-01-27 12:36 azanella at linux dot vnet.ibm.com
2015-01-28 11:04 ` [Bug math/17885] " azanella at linux dot vnet.ibm.com
0 siblings, 1 reply; 2+ messages in thread
From: azanella at linux dot vnet.ibm.com @ 2015-01-27 12:36 UTC (permalink / raw)
To: glibc-bugs
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-28 11:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-27 12:36 [Bug math/17885] New: powerpc: fesetexceptflag not correct setting the new flag azanella at linux dot vnet.ibm.com
2015-01-28 11:04 ` [Bug math/17885] " azanella at linux dot vnet.ibm.com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).