This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [attention machine maintainers] [PATCH] <math.h> issignaling

On Fri, 22 Mar 2013, Thomas Schwinge wrote:

> PowerPC -m64:
> math/basic-test.out:
>     Failure:  double x = (double) (long double) sNaN, !issignaling
> That is, this type cast -- which is a IEEE 754-2008 general-computational
> convertFormat operation (IEEE 754-2008, 5.4.2) -- does not turn the sNaN
> into a qNaN (whilst raising an INVALID exception; not checked here),
> which is contrary to IEEE 754-2008 5.1 and 7.2.  This I consider a
> compiler issue (powerpc-linux-gnu-gcc (Sourcery CodeBench 2012.09-92)
> 4.7.2).

Such a bug (assuming present in GCC trunk for 4.9) should be filed in GCC 
Bugzilla (and I suppose a new math-tests.h macro used to disable the test 
in question for older compilers).  Though I guess it might only be desired 
to change this for -fsignaling-nans.

> MIPS32 O32:
> math/test-double.out, math/test-idouble.out:
>     Result:
>      is:         sNaN
>      should be:  qNaN
> Seen for qNaN inputs with: pow, remainder.

The issue for remainder comes from the use of NaN representations in 
sysdeps/ieee754/dbl-64/e_remainder.c.  In all such cases, for NaN input an 
output NaN should be generated by arithmetic involving the inputs, and for 
non-NaN input an output NaN should be generated by an arithmetic operation 
that generates a NaN and raises INVALID (without other exceptions).  The 
cases of missing INVALID for this (which only appear with -lieee, so need 
testsuite enhancements to test that case in order to be able to test fixes 
for them) are bug 14686.

As usual, file bugs with testcases in glibc Bugzilla for the MIPS-specific 
problems before fixing them.

> diff --git NEWS NEWS
> index f0965d6..0d70ead 100644
> --- NEWS
> +++ NEWS
> @@ -26,6 +26,8 @@ Version 2.18
>  * Added a benchmark framework to track performance of functions in glibc.
> +* New <math.h> macro named issignaling to check for a signaling NaN (sNaN).
> +  This is currently GNU-specific.

"GNU-specific" is a bit misleading there.  I think you mean "only defined 
if _GNU_SOURCE is defined" (but you should note it comes from draft TS 

> +@comment math.h
> +@comment GNU
> +@deftypefn {Macro} int issignaling (@emph{float-type} @var{x})
> +This macro returns a nonzero value if @var{x} is a signaling NaN
> +(sNaN).  It is a GNU extension.

A GNU extension based on draft TS 18661.

> +#undef __issignaling

Why the #undef?

> +int __issignaling (double x)

Return type on a separate line.

Same comments apply to the other implementations.

> +{
> +  u_int32_t hxi;

(I tend to think that the C99 names such as uint32_t should be preferred, 
but since the libm code seems to be using the legacy names universally, 
any such change should probably first be made globally to existing code if 
there's consensus, rather than making this code in particular different.)

Joseph S. Myers

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]