The following snipped of code compiled with -Wall emits two times the same warning :
#include <stdio.h> #include <stdint.h> #include <stdlib.h> int main(void) { uint32_t foo = 42; char bar[] = "bla"; char *buffer = malloc(10); snprintf(buffer, 10, "%lu %s\n", foo, bar); free(buffer); return 0; } gcc -Wall bug.c bug.c: In function 'main': bug.c:11: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'uint32_t' bug.c:11: warning: format '%lu' expects type 'long unsigned int', but argument 4 has type 'uint32_t' I tried on several flavors (4.0.3, 4.0.4, 4.1.2), the result is the same. If sprintf is used instead of snprintf, the warning is emitted only one time. Tests were made on x68 platforms with gcc for x86 and mipsel -- Summary: Warning issued two times with snprintf Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pf dot hugues at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29358