From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A68503858D1E; Sat, 6 May 2023 17:44:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A68503858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683395060; bh=cccTtBbYFxDl7bhIUXWCu7kqkTROMBZ9Msq+VMdSjSA=; h=From:To:Subject:Date:From; b=U0spjGZ3bsyd6PhNlEprzJ9PLziGnR1O0ugNFgRECglcwQUNJ6RWcXut5Pmw73VRb 7juE1/dp8ngd2Fce9aD1iSykPtU2Kc8NA20zPu3nROc9SPPLcvkRhHyfpd1a7duBcn WJ1chDFN2FSgwNU/eTzqU1FS5pRHM6k3w5HIgr7Y= From: "g.peterhoff@t-online.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug libquadmath/109758] New: quadmath abs Date: Sat, 06 May 2023 17:44:20 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libquadmath X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: g.peterhoff@t-online.de X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 Bug ID: 109758 Summary: quadmath abs Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libquadmath Assignee: unassigned at gcc dot gnu.org Reporter: g.peterhoff@t-online.de Target Milestone: --- Hello gcc-team, Problem: #include #include #include #include using T =3D __float128; int main() { const T=20 neg_nan_v =3D -std::numeric_limits::quiet_NaN(); std::cout << neg_nan_v << std::endl; std::cout << "std::abs " << std::abs(neg_nan_v) << std::endl; std::cout << "fabsq " << fabsq(neg_nan_v) << std::endl; std::cout << "builtin " << __builtin_fabsf128(neg_nan_v) << std::endl; } -nan std::abs -nan fabsq nan builtin nan The problem can be found in bits/std_abs.h: #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) __extension__ inline _GLIBCXX_CONSTEXPR __float128 abs(__float128 __x) { return __x < 0 ? -__x : __x; } #endif Is this actually correct? If I compile with -U__STRICT_ANSI__ or remove/com= ment abs from bits/std_abs.h abs falls back to fabsq, which then also works. With std::abs(float/double/...) this problem does not occur. Wouldn't it make sense in principle to also provide a C++ header (quadmath.hpp)? #include namespace std { math-functions to_string/to_wstring to_chars/from_chars operator<< operator>> ... } thx Gero=