public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/110149] New: std::format for pointer arguments allows a '0' option
@ 2023-06-06 21:05 bruno at clisp dot org
  2023-06-06 22:20 ` [Bug libstdc++/110149] " redi at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: bruno at clisp dot org @ 2023-06-06 21:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110149

            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=55275&action=edit
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
§ 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 other
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 and
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 line
28 and in line 29.

How to reproduce:
1)
$ g++ -Wall -std=gnu++20 bug.cc
<no error>
2) Enable line 18 or line 19 or line 23 or line 24.
$ g++ -Wall -std=gnu++20 bug.cc
<compilation error>

Note also that the '0' option cannot be part of a width specification, because
the width cannot start with '0'.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-06-29 23:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-06 21:05 [Bug libstdc++/110149] New: std::format for pointer arguments allows a '0' option bruno at clisp dot org
2023-06-06 22:20 ` [Bug libstdc++/110149] " redi at gcc dot gnu.org
2023-06-06 22:46 ` redi at gcc dot gnu.org
2023-06-06 22:57 ` redi at gcc dot gnu.org
2023-06-08 12:59 ` redi at gcc dot gnu.org
2023-06-09 12:09 ` cvs-commit at gcc dot gnu.org
2023-06-09 12:21 ` redi at gcc dot gnu.org
2023-06-29 23:01 ` cvs-commit at gcc dot gnu.org
2023-06-29 23:02 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).