This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Make fallback fegetexceptflag work with generic fetestexceptflag [committed]
- From: Joseph Myers <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Thu, 12 Jan 2017 01:53:28 +0000
- Subject: Make fallback fegetexceptflag work with generic fetestexceptflag [committed]
- Authentication-results: sourceware.org; auth=none
The generic implementation of fetestexceptflag does:
int
fetestexceptflag (const fexcept_t *flagp, int excepts)
{
/* Most versions of fegetexceptflag store exceptions in a form such
that this works. */
return *flagp & excepts & FE_ALL_EXCEPT;
}
In the case where FE_ALL_EXCEPT is nonzero but exceptions may not be
supported at runtime, this only works if fegetexceptflag cleared all
the bits of FE_ALL_EXCEPT in *flagp; otherwise it accesses
uninitialized data. This showed up as a failure of
math/test-fetestexceptflag for MIPS o32 soft-float. This patch makes
the fallback fegetexceptflag store 0 (fexcept_t is an integer type
everywhere) so that this works. (No bug report in Bugzilla because
this wasn't user-visible - at least, without using tools to detect
uninitialized memory use at runtime - without fetestexceptflag, which
is new in 2.25.)
Tested for MIPS o32 soft-float. Committed.
2017-01-12 Joseph Myers <joseph@codesourcery.com>
* math/fgetexcptflg.c (__fegetexceptflag): Store 0 in fexcept_t
object.
diff --git a/math/fgetexcptflg.c b/math/fgetexcptflg.c
index 8e16250..95a9217 100644
--- a/math/fgetexcptflg.c
+++ b/math/fgetexcptflg.c
@@ -24,6 +24,7 @@ int
__fegetexceptflag (fexcept_t *flagp, int excepts)
{
/* Nothing to do. */
+ *flagp = 0;
return 0;
}
#if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
--
Joseph S. Myers
joseph@codesourcery.com