From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 86BE3385C404; Wed, 6 Oct 2021 14:15:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 86BE3385C404 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98216] [C++20] template mangling for double template argument is wrong Date: Wed, 06 Oct 2021 14:15:41 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: ABI, wrong-code 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: ppalka 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 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, 06 Oct 2021 14:15:41 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98216 --- Comment #10 from CVS Commits --- The releases/gcc-11 branch has been updated by Patrick Palka : https://gcc.gnu.org/g:1682576e62d41cd761472943372b83aee514254a commit r11-9083-g1682576e62d41cd761472943372b83aee514254a Author: Patrick Palka Date: Fri Sep 24 12:36:26 2021 -0400 real: fix encoding of negative IEEE double/quad values [PR98216] In encode_ieee_double/quad, the assignment unsigned long WORD =3D r->sign << 31; is intended to set the 31st bit of WORD whenever the sign bit is set. But on LP64 hosts it also unintentionally sets the upper 32 bits of WOR= D, because r->sign gets promoted from unsigned:1 to int and then the result of the shift (equal to INT_MIN) gets sign extended from int to long. In the C++ frontend, this bug causes incorrect mangling of negative floating point values because the output of real_to_target called from write_real_cst unexpectedly has the upper 32 bits of this word set, which the caller doesn't mask out. This patch fixes this by avoiding the unwanted sign extension. Note that r0-53976 fixed the same bug in encode_ieee_single long ago. PR c++/98216 PR c++/91292 gcc/ChangeLog: * real.c (encode_ieee_double): Avoid unwanted sign extension. (encode_ieee_quad): Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/nontype-float2.C: New test. (cherry picked from commit 34947d4e97ee72b26491cfe5ff4fa8258fadbe95)=