From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A0F233821FDF; Thu, 15 Sep 2022 16:11:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0F233821FDF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663258316; bh=WwWO10c2nfuy8P0vPStpGc6hzaQc3mzDewDN/Rg66K4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=To/+0A0ATM4nUi9B98y2y+5b85dTE/i1A9ZcU8N6B0xi9v6DlMLotQiE4GtwBiQ5A oTlPVuLcaktXyTnU4SAfUXICW6J0yr+DTNqfkSootBdel4RBRasM5aNuHsNuCSW2cr NQSpiPUHHsiOdO7yPbcrVV2WwJg68WixBGmgcLSw= From: "fantasquex at gmail dot com" To: glibc-bugs@sourceware.org Subject: [Bug build/29501] Check failed on stdlib/tst-strfrom while building for RISCV64 on a unmatched hardware Date: Thu, 15 Sep 2022 16:11:56 +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: fantasquex at gmail dot com 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 #7 from Letu Ren --- The root cause is that in function STRFROM of stdlib/strfrom-skeleton.c ```c /* Single-precision values need to be stored in a double type, because __printf_fp_l and __printf_fphex do not accept the float type. */ union { double flt; FLOAT value; } fpnum; const void *fpptr; fpptr =3D &fpnum; /* Single-precision values need to be converted into double-precision, because __printf_fp and __printf_fphex only accept double and long double as the floating-point argument. */ if (__builtin_types_compatible_p (FLOAT, float)) fpnum.flt =3D f; else fpnum.value =3D f; ``` argument f with type float is converted to double in the beginning. On risc= v64, -NAN with type float doesn't keep signbit when it is converted to double. T= hat is why this testcase only fails with strfromf. I have confirmed that if the signbit is kept, the testcase will pass. I'm really curious why the implementation converts the argument to double in the beginning and look through 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 c= haracter %, an optional precision that does not contain an asterisk *, and= one of the conversion specifiers a, A, e, E, f, F, g, or G, which applies = to the type (double, float, or long double) indicated by the function suffi= x (rather than by a length modifier). Use of these functions with any othe= r 20 format string results in undefined behavior. Since `snprintf` doesn't consume an argument with type double, there must b= e a conversion from float to double. According to spec of IEEE 754 and RISCV-ISA manual, all these behaviors are reasonable. The signbit of NAN doesn't matt= er. I understand what you mean a hook. Get the signbit of the argument, copy the value and also copy the signbit explicitly. As I mentioned before, all curr= ent behaviors are reasonable according to the spec. I really doubt whether we should add such a hook to resolve a problem which shouldn't be a problem. --=20 You are receiving this mail because: You are on the CC list for the bug.=