From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9CD793851514; Fri, 28 Oct 2022 14:49:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9CD793851514 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666968582; bh=fceySV2/pA+DzFMT2mBgpgHU3vg1dLrE09rrWg1CSxA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=G4qbJzBUDoHoIwN8dQdPOtfzsSVlcJvNbmPNMqZqSRllvmGlUlpqM5WdPR5IsBnVk zCFOeF3XkUCWTWV1U3Ra2Uclrl7/uZxYoIInk7en7T+xJps5yMbmhbkKxasOQOQQLD 9bDR5HwUcURW2xJ4Jv47peMKJRGavxIaN8S+yRCQ= From: "cvs-commit at gcc dot gnu.org" To: glibc-bugs@sourceware.org Subject: [Bug build/29501] Check failed on stdlib/tst-strfrom while building for RISCV64 on a unmatched hardware Date: Fri, 28 Oct 2022 14:49:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: build X-Bugzilla-Version: 2.36 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29501 --- Comment #8 from cvs-commit at gcc dot gnu.org --- The master branch has been updated by Adhemerval Zanella : https://sourceware.org/git/gitweb.cgi?p=3Dglibc.git;h=3D0cc0033ef19bd337844= 5c2b851e53d7255cb1b1e commit 0cc0033ef19bd3378445c2b851e53d7255cb1b1e Author: Letu Ren Date: Fri Oct 21 22:54:50 2022 +0800 stdlib/strfrom: Add copysign to fix NAN issue on riscv (BZ #29501) According to the specification of ISO/IEC TS 18661-1:2014, The strfromd, strfromf, and strfroml functions are equivalent to snprintf(s, n, format, fp) (7.21.6.5), except the format string contains only the character %, an optional precision that does not contain an asteris= k *, and one of the conversion specifiers a, A, e, E, f, F, g, or G, which appli= es to the type (double, float, or long double) indicated by the function suff= ix (rather than by a length modifier). Use of these functions with any ot= her 20 format string results in undefined behavior. strfromf will convert the arguement with type float to double first. According to the latest version of IEEE754 which is published in 2019, Conversion of a quiet NaN from a narrower format to a wider format in t= he same radix, and then back to the same narrower format, should not change the quiet NaN payload in any way except to make it canonical. When either an input or result is a NaN, this standard does not interpr= et the sign of a NaN. However, operations on bit strings=C3=A2copy, negate, ab= s, copySign=C3=A2specify the sign bit of a NaN result, sometimes based upo= n the sign bit of a NaN operand. The logical predicates totalOrder and isSignMinus= are also affected by the sign bit of a NaN operand. For all other operation= s, this standard does not specify the sign bit of a NaN result, even when there= is only one input NaN, or when the NaN is produced from an invalid operation. converting NAN or -NAN with type float to double doesn't need to keep the signbit. As a result, this test case isn't mandatory. The problem is that according to RISC-V ISA manual in chapter 11.3 of riscv-isa-20191213, Except when otherwise stated, if the result of a floating-point operati= on is NaN, it is the canonical NaN. The canonical NaN has a positive sign and= all significand bits clear except the MSB, a.k.a. the quiet bit. For single-precision floating-point, this corresponds to the pattern 0x7fc00000. which means that conversion -NAN from float to double won't keep the signbit. Since glibc ought to be consistent here between types and architectures, this patch adds copysign to fix this problem if the string is NAN. This patch adds two different functions under sysdeps directory to work around the issue. This patch has been tested on x86_64 and riscv64. Resolves: BZ #29501 v2: Change from macros to different inline functions. v3: Add unlikely check to isnan. v4: Fix wrong commit message header. v5: Fix style: add space before parentheses. v6: Add copyright. Signed-off-by: Letu Ren Reviewed-by: Adhemerval Zanella --=20 You are receiving this mail because: You are on the CC list for the bug.=