From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C05983858D28; Sun, 7 May 2023 10:04:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C05983858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683453867; bh=tSb8SO2LAbunP7UHjzg1qi/+YKk9cNhhH3Zs2U1R67k=; h=From:To:Subject:Date:In-Reply-To:References:From; b=M0VTXwMfShshDSduOEKK82FZdFQ7veLdprDQE6zD/G40FWUQ+9Xb1Y/vkS4qfoK+D XWuH62VTD99IHLXyiQAJ/03dh/v5kc+wtmDWl83+JK5ghK2dQTC6+Lv4NBv+KluXBA wuyp5F1EU7lga0ekfeBP2SPEAh0jaxdhDraO0DzE= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/109758] std::abs(__float128) doesn't support NaN Date: Sun, 07 May 2023 10:04:27 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.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://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 #8 from Jakub Jelinek --- What does the committee have to do with the GCC implementation? I guess what we could do is: --- libstdc++-v3/include/bits/std_abs.h 2023-01-16 11:52:16.917721774 +0100 +++ libstdc++-v3/include/bits/std_abs.h 2023-05-07 12:01:03.716627026 +0200 @@ -135,7 +135,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __extension__ inline _GLIBCXX_CONSTEXPR __float128 abs(__float128 __x) - { return __x < 0 ? -__x : __x; } + { +#if __has_builtin(__builtin_fabsf128) + return __builtin_fabsf128(__x); +#else + return __x < 0 ? -__x : __x; +#endif + } #endif _GLIBCXX_END_NAMESPACE_VERSION If the builtin isn't supported, perhaps we could use bit_cast if supported = to toggle the sign bit if we know where it is, but if that isn't supported eit= her, there is nothing we can do, as the function needs to be constexpr.=