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