This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Incorrect warning about printf %0<fieldwidth>p format
- From: Jim Avera <jima at cadence dot com>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 07 May 2003 09:01:09 -0700
- Subject: Incorrect warning about printf %0<fieldwidth>p format
- Organization:
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