[PATCH] Fix truncf for sNaN input

Corinna Vinschen vinschen@redhat.com
Wed Mar 11 11:13:35 GMT 2020


On Mar 11 10:58, Fabian Schriever wrote:
> Make line 47 in sf_trunc.c reachable. While converting the double
> precision function trunc to the single precision version truncf an error
> was introduced into the special case. This special case is meant to
> catch both NaNs and infinities, however qNaNs and infinities work just
> fine with the simple return of x (line 51). The only error occurs for
> sNaNs where the same sNaN is returned and no invalid exception is
> raised.
> ---
>  newlib/libm/common/sf_trunc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/newlib/libm/common/sf_trunc.c b/newlib/libm/common/sf_trunc.c
> index 74ea933ce..8eb0554d8 100644
> --- a/newlib/libm/common/sf_trunc.c
> +++ b/newlib/libm/common/sf_trunc.c
> @@ -42,7 +42,7 @@
>      }
>    else
>      {
> -      if (exponent_less_127 == 255)
> +      if (exponent_less_127 == 128)
>          /* x is NaN or infinite. */
>          return x + x;
>  
> -- 
> 2.24.1.windows.2
> 

Pushed.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20200311/fa2c41be/attachment.sig>


More information about the Newlib mailing list