From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id EC63D385F022; Wed, 11 Mar 2020 11:11:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC63D385F022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1583925080; bh=SlNRMbU1suV/op4Gzj/uvR657u9ZVlYAhE4+Jjg5Bz8=; h=From:To:Subject:Date:From; b=YBYKorndZhxlbTOF+kYbtEYKXSQE7O+yp+4Zw0yN9wct7QhcR5Y4e4WwDvgOjlu/Y h1v5el7UEdQZc8/+2HLf/5yCUd46P3fkGCzAuEQ2xxwfdTOA9hyDJLoeg+mH7FzNvL i4RnBLBRjS7J0DRQsIzzG61C3jdM23jqmuhEf7fM= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] Fix truncf for sNaN input X-Act-Checkin: newlib-cygwin X-Git-Author: Fabian Schriever X-Git-Refname: refs/heads/master X-Git-Oldrev: 91a8d0c90767f82202e08ba7e3fd6b4e1419ec00 X-Git-Newrev: c56f53a2a04577f6e84ac96477fc8dc804d544ef Message-Id: <20200311111120.EC63D385F022@sourceware.org> Date: Wed, 11 Mar 2020 11:11:20 +0000 (GMT) X-BeenThere: newlib-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2020 11:11:21 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=c56f53a2a04577f6e84ac96477fc8dc804d544ef commit c56f53a2a04577f6e84ac96477fc8dc804d544ef Author: Fabian Schriever Date: Wed Mar 11 10:58:05 2020 +0100 Fix truncf for sNaN input 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. Diff: --- 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;