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

--- Comment #7 from Jonny Grant <jg at jguk dot org> ---
https://godbolt.org/z/bhnbsb

Another example where %ld suggests to replace with %ld


#include <cstdio>

int main()
{
    size_t i = 0;
    std::printf("%ld", i);
}

 -Wall -Wformat-signedness

x86-64 gcc (trunk) - 600ms (19538B)
#1 with x86-64 gcc (trunk)
<source>: In function 'int main()':
<source>:6:20: warning: format '%ld' expects argument of type 'long int', but
argument 2 has type 'size_t' {aka 'long unsigned int'} [-Wformat=]
    6 |     std::printf("%ld", i);
      |                  ~~^   ~
      |                    |   |
      |                    |   size_t {aka long unsigned int}
      |                    long int
      |                  %ld
Compiler returned: 0

Reply via email to