From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1911C3858C3A; Thu, 9 Feb 2023 16:52:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1911C3858C3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675961553; bh=HMBnKxvBKlrRMapFMuFVNs77wr91W91ptC5LXsZijyg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EX+6yDSUyF388WgFdxqYJSlCsPfgT0IJcksE/DeIU2Byqd76gmwaoOHWTig1QoJUz XFlnxVGnSYIBk/TJ3ozcfMcQsixnXS3f2GdI5eKxHUTdm1Qa1XGRQXErcyC/wTYvxM q0eXGMCzc+dTR5+mf9LNbMb0zU3gM9+bQhEHU/CA= From: "matz at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/108742] Incorrect constant folding with (or exposed by) -fexcess-precision=standard Date: Thu, 09 Feb 2023 16:52:32 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: matz 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=3D108742 --- Comment #7 from Michael Matz --- (In reply to Jakub Jelinek from comment #5) > https://eel.is/c++draft/cfloat.syn points to the C standard for > FLT_EVAL_METHOD > (plus https://eel.is/c++draft/expr#pre-6 talks about excess precision too) > and e.g. C17 > 5.2.4.2.2/9): > "2 evaluate all operations and constants to the range and precision of the > long double type." >=20 > Note the " and constants" above. Yes. But that leaves unspecified exactly to what bit pattern the string "4= .2" should be converted to. Both values used (0x8.666666666666666p-1 and 0x8.6666666666668p-1) are in "the range and precision of the long doubel ty= pe". For that: 6.4.4.2 Floating constants (sorry, only c11 here, I hope wording = to same effect is still in c17): 4 An unsuffixed floating constant has type double. If suffixed by the lette= r f or F... 5 Floating constants are converted to internal format as if at translation-time. ... So, my interpretation is that unsuffixed "4.2" has to be the double constant 4.2 (in IEEE double aka 0x1.0cccccccccccdp+2), which is then, because of FLT_EVAL_METHOD, evaluated to "range and precision of long double" leading to 0x8.6666666666668p-1, not to 0x8.666666666666666p-1 .=