[Bug c++/98819] New: -Wall -Wformat-signedness suggests %u for %u
jg at jguk dot org
gcc-bugzilla@gcc.gnu.org
Mon Jan 25 10:22:44 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98819
Bug ID: 98819
Summary: -Wall -Wformat-signedness suggests %u for %u
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jg at jguk dot org
Target Milestone: ---
Reproduced in latest Godbolt trunk
%u is suggested for %u
#1 with x86-64 gcc (trunk)
<source>: In function 'int main()':
<source>:6:19: warning: format '%u' expects argument of type 'unsigned int',
but argument 2 has type 'int' [-Wformat=]
6 | std::printf("%u", CURRENT_YEAR);
| ~^
| |
| unsigned int
| %u
Compiler returned: 0
#include <cstdio>
#define CURRENT_YEAR 2021
int main()
{
std::printf("%u", CURRENT_YEAR);
}
More information about the Gcc-bugs
mailing list