Martin,
Thanks for all your work.
I couldn't locate mingw-w64-crt/math/x86/pow.def.h on the internet (URL ?),
but I assume the patch is concerned with raising a NaN to a power.
Given that raising an input NaN to a power does not always result in a NaN,
it seems a little suspicious that this has come up under the subject
"properly propagate input NANs".

In short - I'm simply seeking reassurance that the case of raising a NaN to
the power of zero is still being correctly handled.

Cheers,
Rob



On Wed, Jul 31, 2019 at 7:08 AM Martin Storsjö <[email protected]> wrote:

> While the C99 standard doesn't explicitly require this, the standard
> says it is recommended (F.9.13).
>
> Signed-off-by: Martin Storsjö <[email protected]>
> ---
>  mingw-w64-crt/math/arm-common/remquo.c  |  4 ++++
>  mingw-w64-crt/math/arm-common/remquof.c |  4 ++++
>  mingw-w64-crt/math/erfl.c               |  3 +++
>  mingw-w64-crt/math/lgammal.c            |  2 +-
>  mingw-w64-crt/math/tgammal.c            |  2 +-
>  mingw-w64-crt/math/x86/acosh.def.h      |  7 ++++++-
>  mingw-w64-crt/math/x86/log.def.h        |  4 ++--
>  mingw-w64-crt/math/x86/pow.def.h        | 10 +++++++---
>  8 files changed, 28 insertions(+), 8 deletions(-)
>
> diff --git a/mingw-w64-crt/math/arm-common/remquo.c
> b/mingw-w64-crt/math/arm-common/remquo.c
> index 6a97ade22..d8ec534fd 100644
> --- a/mingw-w64-crt/math/arm-common/remquo.c
> +++ b/mingw-w64-crt/math/arm-common/remquo.c
> @@ -9,6 +9,10 @@
>
>  double remquo(double x, double y, int *quo)
>  {
> +  if (isnan(x))
> +    return x;
> +  if (isnan(y))
> +    return y;
>    if (isinf(x) || y == 0)
>      return NAN;
>    double div = x/y;
> diff --git a/mingw-w64-crt/math/arm-common/remquof.c
> b/mingw-w64-crt/math/arm-common/remquof.c
> index c395b2bdd..d92800294 100644
> --- a/mingw-w64-crt/math/arm-common/remquof.c
> +++ b/mingw-w64-crt/math/arm-common/remquof.c
> @@ -9,6 +9,10 @@
>
>  float remquof(float x, float y, int *quo)
>  {
> +  if (isnan(x))
> +    return x;
> +  if (isnan(y))
> +    return y;
>    if (isinf(x) || y == 0)
>      return NAN;
>    float div = x/y;
> diff --git a/mingw-w64-crt/math/erfl.c b/mingw-w64-crt/math/erfl.c
> index 50dcbb350..1408cf542 100644
> --- a/mingw-w64-crt/math/erfl.c
> +++ b/mingw-w64-crt/math/erfl.c
> @@ -254,6 +254,9 @@ long double erfcl(long double a)
>         if (isinf (a))
>                 return (signbit(a) ? 2.0 : 0.0);
>
> +       if (isnan (a))
> +               return (a);
> +
>         x = fabsl (a);
>
>         if (x < 1.0L)
> diff --git a/mingw-w64-crt/math/lgammal.c b/mingw-w64-crt/math/lgammal.c
> index 1806750c4..998c6a90d 100644
> --- a/mingw-w64-crt/math/lgammal.c
> +++ b/mingw-w64-crt/math/lgammal.c
> @@ -225,7 +225,7 @@ long double __lgammal_r(long double x, int* sgngaml)
>         *sgngaml = 1;
>  #ifdef NANS
>         if (isnanl(x))
> -               return(NANL);
> +               return x;
>  #endif
>  #ifdef INFINITIES
>         if (!isfinitel(x))
> diff --git a/mingw-w64-crt/math/tgammal.c b/mingw-w64-crt/math/tgammal.c
> index 18d32441f..eb8994e07 100644
> --- a/mingw-w64-crt/math/tgammal.c
> +++ b/mingw-w64-crt/math/tgammal.c
> @@ -280,7 +280,7 @@ long double __tgammal_r(long double x, int* sgngaml)
>         *sgngaml = 1;
>  #ifdef NANS
>         if (isnanl(x))
> -               return (NANL);
> +               return x;
>  #endif
>  #ifdef INFINITIES
>  #ifdef NANS
> diff --git a/mingw-w64-crt/math/x86/acosh.def.h
> b/mingw-w64-crt/math/x86/acosh.def.h
> index 329799dca..3a7e07763 100644
> --- a/mingw-w64-crt/math/x86/acosh.def.h
> +++ b/mingw-w64-crt/math/x86/acosh.def.h
> @@ -50,7 +50,12 @@ __FLT_TYPE
>  __FLT_ABI(acosh) (__FLT_TYPE x)
>  {
>    int x_class = fpclassify (x);
> -  if (x_class == FP_NAN || x < __FLT_CST(1.0))
> +  if (x_class == FP_NAN)
> +    {
> +      __FLT_RPT_DOMAIN ("acosh", x, 0.0, x);
> +      return x;
> +    }
> +  else if (x < __FLT_CST(1.0))
>      {
>        __FLT_RPT_DOMAIN ("acosh", x, 0.0, __FLT_NAN);
>        return __FLT_NAN;
> diff --git a/mingw-w64-crt/math/x86/log.def.h
> b/mingw-w64-crt/math/x86/log.def.h
> index 9428f90ce..a0d54b73d 100644
> --- a/mingw-w64-crt/math/x86/log.def.h
> +++ b/mingw-w64-crt/math/x86/log.def.h
> @@ -56,6 +56,8 @@ __FLT_ABI(log) (__FLT_TYPE x)
>        __FLT_RPT_ERANGE ("log", x, 0.0, -__FLT_HUGE_VAL, 1);
>        return -__FLT_HUGE_VAL;
>      }
> +  else if (x_class == FP_NAN)
> +    return x;
>    else if (signbit (x))
>      {
>        __FLT_RPT_DOMAIN ("log", x, 0.0, __FLT_NAN);
> @@ -63,7 +65,5 @@ __FLT_ABI(log) (__FLT_TYPE x)
>      }
>    else if (x_class == FP_INFINITE)
>      return __FLT_HUGE_VAL;
> -  else if (x_class == FP_NAN)
> -    return __FLT_NAN;
>    return (__FLT_TYPE) __logl_internal ((long double) x);
>  }
> diff --git a/mingw-w64-crt/math/x86/pow.def.h
> b/mingw-w64-crt/math/x86/pow.def.h
> index 375b02b9d..0cf0739fe 100644
> --- a/mingw-w64-crt/math/x86/pow.def.h
> +++ b/mingw-w64-crt/math/x86/pow.def.h
> @@ -121,9 +121,13 @@ __FLT_ABI(pow) (__FLT_TYPE x, __FLT_TYPE y)
>      return __FLT_CST(1.0);
>    else if (x_class == FP_NAN || y_class == FP_NAN)
>      {
> -      rslt = (signbit(x) ? -__FLT_NAN : __FLT_NAN);
> -      __FLT_RPT_DOMAIN ("pow", x, y, rslt);
> -      return rslt;
> +      if (x_class == FP_NAN) {
> +        __FLT_RPT_DOMAIN ("pow", x, y, x);
> +        return x;
> +      } else {
> +        __FLT_RPT_DOMAIN ("pow", x, y, y);
> +        return y;
> +      }
>      }
>    else if (x_class == FP_ZERO)
>      {
> --
> 2.17.1
>
>
>
> _______________________________________________
> Mingw-w64-public mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to