From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 38F683858D38; Tue, 6 Jun 2023 21:05:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38F683858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686085505; bh=3py5dhIv8IU3vAeDtsVjdtITitsUbNd8vkGfw2y6Xd4=; h=From:To:Subject:Date:From; b=PmGp2zALsB2gLya3sd2yPIuzVAWIVr2OF2FpPLzH7hIk2ImTeebovxwiDw7aGEVLF 9PfdPuDBl3Uh2I00fH883sQIQJOuI3xUYVVbgcCqDYs/TDSusSQeT5oyGAmNJksvi5 LuXWyPqbznvbqcExh5d6WQiYffgM7E7jkgJrBf30= From: "bruno at clisp dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/110149] New: std::format for pointer arguments allows a '0' option Date: Tue, 06 Jun 2023 21:05:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bruno at clisp dot org 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 attachments.created 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=3D110149 Bug ID: 110149 Summary: std::format for pointer arguments allows a '0' option Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: bruno at clisp dot org Target Milestone: --- Created attachment 55275 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D55275&action=3Dedit test case bug.cc In C++ 20, a sign, a '#' option, and a '0' option are disallowed for std::format strings with a pointer argument. The text has the same language= for all three: In https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/n4950.pdf =C2=A7 22.14.2.2 Standard format specifiers [format.string.std] Paragraph 5: "The sign option is only valid for arithmetic types other than charT and bool or when an integer presentation type is specified." Paragraph 7: "The # option .... This option is valid for arithmetic types o= ther than charT and bool or when an integer presentation type is specified, and = not otherwise." Paragraph 8: "The 0 option is valid for arithmetic types other than charT a= nd bool or when an integer presentation type is specified." Paragraph 21 specifies the available integer presentation types; 'p' is not= one of them, it is listed in paragraph 25 instead. Therefore in the attached program bug.cc, an error should be signalled in l= ine 28 and in line 29. How to reproduce: 1) $ g++ -Wall -std=3Dgnu++20 bug.cc 2) Enable line 18 or line 19 or line 23 or line 24. $ g++ -Wall -std=3Dgnu++20 bug.cc Note also that the '0' option cannot be part of a width specification, beca= use the width cannot start with '0'.=