[PATCH] Cygwin: fix return value of sqrtl on negative infinity

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Oct 27 14:15:41 GMT 2020


On Oct 27 10:10, Ken Brown via Cygwin-patches wrote:
> The return value is now -NaN.
> 
> This fixes a bug in the mingw-w64 code that was imported into Cygwin.
> The fix is consistent with Posix and Linux.  It is also consistent
> with the current mingw-w64 code, with one exception: The mingw-w64
> code sets errno to EDOM if the input is -NaN, but this appears to
> differ from Posix and Linux.
> 
> Addresses: https://cygwin.com/pipermail/cygwin/2020-October/246606.html
> ---
>  winsup/cygwin/math/sqrt.def.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/winsup/cygwin/math/sqrt.def.h b/winsup/cygwin/math/sqrt.def.h
> index cf8b5cbe6..3d1a00908 100644
> --- a/winsup/cygwin/math/sqrt.def.h
> +++ b/winsup/cygwin/math/sqrt.def.h
> @@ -73,8 +73,11 @@ __FLT_ABI (sqrt) (__FLT_TYPE x)
>        if (x_class == FP_ZERO)
>  	return __FLT_CST (-0.0);
>  
> +      if (x_class == FP_NAN)
> +	return x;
> +
>        errno = EDOM;
> -      return x;
> +      return -__FLT_NAN;
>      }
>    else if (x_class == FP_ZERO)
>      return __FLT_CST (0.0);
> -- 
> 2.28.0

LGTM


Thanks,
Corinna


More information about the Cygwin-patches mailing list