Incorrect warning about printf %0<fieldwidth>p format

Falk Hueffner falk.hueffner@student.uni-tuebingen.de
Wed May 7 18:24:00 GMT 2003


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



More information about the Gcc-bugs mailing list