https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80619
Bug ID: 80619 Summary: bad fix-it hint for GCC %lu directive with int argument: %wu Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- When the %lu printf directive in a function decorated with attribute format __gcc_diag__ is passed an int argument GCC issues a warning as expected, but then proceeds to suggest to replace the directive with %wu. This suggestion is wrong because %wu expects an unsigned HOST_WIDE_INT argument, a type that is typically wider than int. The correct hint is "%u". $ cat x.c && gcc -O2 -S -Wall -Wpedantic x.c void f (const char*, ...) __attribute__ ((format (__gcc_diag__, 1, 2))); void h (void) { f ("%lu", 0); } x.c: In function ‘h’: x.c:5:9: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘int’ [-Wformat=] f ("%lu", 0); ~~^ %wu