C99(+TC1), and C11, explicitly say that feclearexcept, feraiseexcept
and fesetexceptflag return zero when their "excepts" operand is zero,
because nothing needs to be done in that case.
I propose this patch to fix the fallback implementations - the ones
for when no exceptions are supported, when no target-specific
implementation is used - to do so; to conform to the C standard
requirements, these operations should always be considered supported
and successful when applied to the empty set of exceptions, even when
no exceptions are supported. Sanity checked with a soft-float MIPS
build.
I submitted this last year
<http://sourceware.org/ml/libc-alpha/2011-01/msg00005.html> but it was
rejected based on an apparent confusion between ISO C and POSIX error
handling rules. The notion of implementations defining additional
error conditions is a POSIX one; here, the semantics are fully defined
by ISO C ("The feclearexcept function returns zero if the excepts
argument is zero or if all the specified exceptions were successfully
cleared.", for example) and it's not valid for the functions to fail
with a zero argument any more than it's valid for memcpy to fail with
valid arguments for some implementation-defined reason.
2012-04-27 Joseph Myers<joseph@codesourcery.com>
[BZ #14027]
* math/fclrexcpt.c (__feclearexcept): Return zero if nothing needs
to be done.
* math/fraiseexcpt.c (__feraiseexcept): Likewise.
* math/fsetexcptflg.c (__fesetexceptflag): Likewise.