From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D428C38582BD; Wed, 27 Sep 2023 16:17:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D428C38582BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1695831458; bh=H3LD0jZ8yXCrX5aboVJ4dtNUVlvNAocpFz31k97+F5s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=yVwIbUv2wfCQfPQ0pF1rfuSTslHf4KdRnatz2B+Rm7nfR2ZQX2zsbFeXKrhHrkCWL jYGCmj/65ZMboghMBmkbfMfC/1uSSJoGnG5xfp1wBesmOjNhDSRrKqxVM7MEm8rNAt CNh7gSSB/UkxOUkeNJVbwPp39uXoT1N5WuRAX+NY= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/108046] The dot in the floating-point alternative form has wrong position Date: Wed, 27 Sep 2023 16:17:37 +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.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.3 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=3D108046 --- Comment #5 from CVS Commits --- The releases/gcc-13 branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:da1ba03245c212ef1ba100e7806588802f3ad46f commit r13-7914-gda1ba03245c212ef1ba100e7806588802f3ad46f Author: Jonathan Wakely Date: Thu Jul 27 14:07:09 2023 +0100 libstdc++: Fix std::format alternate form for floating-point [PR108046] A decimal point was being added to the end of the string for {:#.0} because the __expc character was not being set, for the _Pres_none presentation type, so __s.find(__expc) didn't the 'e' in "1e+01" and so we created "1e+01." by appending the radix char to the end. This can be fixed by ensuring that __expc=3D'e' is set for the _Pres_no= ne case. I realized we can also set __expc=3D'P' and __expc=3D'E' when nee= ded, to save a call to std::toupper later. For the {:#.0g} format, __expc=3D'e' was being set and so the 'e' was found in "1e+10" but then __z =3D __prec - __sigfigs would wraparound to SIZE_MAX. That meant we would decide not to add a radix char because the number of extra characters to insert would be 1+SIZE_MAX i.e. zero. This can be fixed by using __z =3D=3D 0 when __prec =3D=3D 0. libstdc++-v3/ChangeLog: PR libstdc++/108046 * include/std/format (__formatter_fp::format): Ensure __expc is always set for all presentation types. Set __z correctly for zero precision. * testsuite/std/format/functions/format.cc: Check problem cases. (cherry picked from commit 50bc490c090cc95175e6068ed7438788d7fd7040)=