From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 840C838708D9; Wed, 24 Feb 2021 17:26:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 840C838708D9 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/98384] [11 Regression] new test case 20_util/to_chars/long_double.cc in r11-6249 fails on powerpc64 BE Date: Wed, 24 Feb 2021 17:26:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: ppalka at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 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://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Feb 2021 17:26:59 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98384 --- Comment #19 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:70aa0e6eef9d65744f37adc2a3cffef1a8217dc1 commit r11-7367-g70aa0e6eef9d65744f37adc2a3cffef1a8217dc1 Author: Patrick Palka Date: Wed Feb 24 12:24:43 2021 -0500 libstdc++: Robustify long double std::to_chars testcase [PR98384] The long double std::to_chars testcase currently verifies the correctness of its output by comparing it to that of printf, so if there's a mismatch between to_chars and printf, the test FAILs. This works well for the scientific, fixed and general formatting modes, because the corresponding printf conversion specifiers (%e, %f and %g) are rigidly specified. But this doesn't work well for the hex formatting mode because the corresponding printf conversion specifier %a is more flexibly specified. For instance, the hexadecimal forms 0x1p+0, 0x2p-1, 0x4p-2 and 0x8p-3 are all equivalent and valid outputs of the %a specifier for the number= 1. The apparent freedom here is the choice of leading hex digit -- the standard just requires that the leading hex digit is nonzero for normalized numbers. Currently, our hexadecimal formatting implementation uses 0/1/2 as the leading hex digit for floating point types that have an implicit leading mantissa bit which in practice means all supported floating point types except x86 long double. The latter type has a 64 bit mantissa with an explicit leading mantissa bit, and for this type our implementation uses the most significant four bits of the mantissa as leading hex digit. This seems to be consistent with most printf implementations, but not all, as PR98384 illustrates. In order to avoid false-positive FAILs due to arbitrary disagreement between to_chars and printf about the choice of leading hex digit, this patch makes the testcase's verification via printf conditional on the leading hex digits first agreeing. An additional verification step is also added: round-tripping the output of to_chars through from_chars should recover the value exactly. libstdc++-v3/ChangeLog: PR libstdc++/98384 * testsuite/20_util/to_chars/long_double.cc: Include . (test01): Simplify verifying the nearby values by using a 2-iteration loop and a dedicated output buffer to check that the nearby values are different. Factor out the printf-based verification into a local function, and check that the leading hex digits agree before comparing to the output of printf. Also verify the output by round-tripping it through from_chars.=