This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Incorrect warning about printf %0<fieldwidth>p format


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]