public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96412] New: format suggestion issue
@ 2020-08-01 17:17 jg at jguk dot org
  2020-08-02 20:36 ` [Bug c++/96412] " redi at gcc dot gnu.org
  2022-12-26 21:22 ` jg at jguk dot org
  0 siblings, 2 replies; 3+ messages in thread
From: jg at jguk dot org @ 2020-08-01 17:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96412
           Summary: format suggestion issue
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jg at jguk dot org
  Target Milestone: ---

Running on godbolt trunk

The suggestion is '%ld' in green type colour in the terminal, but should it
actually be '%zu' ? 

-Wformat-signedness -Wall



#include <cstdio>
int main()
{
size_t i = 0;
printf("%ld\n", i);
}



#1 with x86-64 gcc (trunk)
<source>: In function 'int main()':

<source>:5:11: warning: format '%ld' expects argument of type 'long int', but
argument 2 has type 'size_t' {aka 'long unsigned int'} [-Wformat=]

    5 | printf("%ld\n", i);

      |         ~~^     ~

      |           |     |

      |           |     size_t {aka long unsigned int}

      |           long int

      |         %ld

Compiler returned: 0

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

end of thread, other threads:[~2022-12-26 21:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-01 17:17 [Bug c++/96412] New: format suggestion issue jg at jguk dot org
2020-08-02 20:36 ` [Bug c++/96412] " redi at gcc dot gnu.org
2022-12-26 21:22 ` jg at jguk dot 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).