Spurious scanf("%zu") warning

Joseph S. Myers jsm28@cam.ac.uk
Wed Mar 29 03:14:00 GMT 2000

GCC snapshot 20000327 on i686-pc-linux-gnu gives a spurious warning about
the use of the %zu format with scanf (using -std=c99 -Wformat).  (My copy
of C99 is currently on order, so I'm presuming here that the same
specification of this format applies as in the last public draft.)

The test case is:

extern int scanf(const char *, ...);

typedef __SIZE_TYPE__ size_t;

size_t foo(void) { size_t t; scanf("%zu", &t); return t; }

Messages given:

$ egcc -std=c99 -Wformat -S scanf-bug.c
scanf-bug.c: In function `foo':
scanf-bug.c:5: warning: use of `z' length character with `u' type character
$ egcc -v
Reading specs from /opt/gcc/snapshot/lib/gcc-lib/i686-pc-linux-gnu/2.96/specs
gcc version 2.96 20000327 (experimental)

Joseph S. Myers

More information about the Gcc-bugs mailing list