Incorrect warning about printf %0<fieldwidth>p format

Jim Avera jima@cadence.com
Wed May 7 16:06:00 GMT 2003


gcc 3.2 (-Wall) incorrectly complains about the following:

     void *ptr;
     printf("The pointer is %010p\n", ptr);

     ...: warning: `0' flag used with `%p' printf format

The '0' flag is perfectly legitimate, and in fact is
required in order to get leading zeroes.  For example, if
the pointer contained hex 1234, the result for "%010p"
will be
  0x00001234
but if you omit the '0' flag and use "%10p", you get
  <space><space><space><space>0x1234

Note that %p automatically implies '#' ("alternate form")
which suppplies the 0x prefix.

-Jim Avera
jima@cadence.com



More information about the Gcc-bugs mailing list