From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BBCA03857735; Thu, 1 Jun 2023 22:44:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BBCA03857735 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685659469; bh=1rfmswwcerprS9bjjVhyEU2N2+fvMvAPgeBC5BFhw5E=; h=From:To:Subject:Date:In-Reply-To:References:From; b=xAGXWUNJNBu670/8bOH8SjCpiKt1EH08d2UubtnX48+P7vweSbTCgzujI/z8ws8Fi xy9DggWkmDmI94ksrPAm1tVhx2/Pps2lPxh1Gfv2p70PEvXV3hzF1o0Y1sp/MZ2Q1s ziQKSWYmxjLeho6D/ya5dW/Pnris2mYXb4IokA/I= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/109758] std::abs(__float128) doesn't support NaN Date: Thu, 01 Jun 2023 22:44:28 +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: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109758 --- Comment #15 from CVS Commits --- The releases/gcc-13 branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:099d469df67d8454aa393d036f4791912364bd4d commit r13-7406-g099d469df67d8454aa393d036f4791912364bd4d Author: Jonathan Wakely Date: Wed May 10 12:20:58 2023 +0100 libstdc++: Fix std::abs(__float128) for -NaN and -0.0 [PR109758] The current implementation of this non-standard overload of std::abs incorrectly returns a negative value for negative NaNs and negative zero, because x < 0 is false in both cases. Use fabsl(long double) or fabsf128(_Float128) if those do the right thing. Otherwise, use __builtin_signbit(x) instead of x < 0 to detect negative inputs. This assumes that __builtin_signbit handles __float128 correctly, but that seems to be true for all of GCC, clang and icc. libstdc++-v3/ChangeLog: PR libstdc++/109758 * include/bits/std_abs.h (abs(__float128)): Handle negative NaN and negative zero correctly. * testsuite/26_numerics/headers/cmath/109758.cc: New test. (cherry picked from commit af595613acbd9863198ae69c7b1c9e856bca9e4f)=