This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Incorrect warning about printf %0<fieldwidth>p format
- From: Falk Hueffner <falk dot hueffner at student dot uni-tuebingen dot de>
- To: Jim Avera <jima at cadence dot com>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: 07 May 2003 20:23:05 +0200
- Subject: Re: Incorrect warning about printf %0<fieldwidth>p format
- References: <1052323269.1853.14.camel@jima-vpn.local>
Jim Avera <jima@cadence.com> writes:
> 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
No, it's not.
§7.19.6.1:
0 For d, i, o, u, x, X, a, A, e, E, f, F, g, and G conversions,
leading zeros (following any indication of sign or base) are used to
pad to the field width rather than performing space padding, except
when converting an infinity or NaN. If the 0 and - flags both
appear, the 0 flag is ignored. For d, i, o, u, x, and X conversions,
if a precision is specified, the 0 flag is ignored. For other
conversions, the behavior is undefined.
--
Falk