printf behaviour with illegal or malformed format string

Poul-Henning Kamp phk at phk.freebsd.dk
Mon Dec 12 07:49:18 PST 2005


In message <200512121643.39236.max at love2party.net>, Max Laier writes:

>I agree on principle but would like to ask if we need to revisit some of the 
>error cases.  Especially with regard to 64bit porting there are some 
>"artifacts" that might cause serious pain for ported applications if the 
>above is adopted.
>
>Specifically, right now the following will warn "long long int format, int64_t 
>arg (arg 2)" on our 64bit architectures while it is required on - at least i386
>
>	int64_t i = 1;
>	printf("%lld", i);

You misunderstood me. 

"%lld" is a legal formatting string, my printf implementation would never
object to that.

I'm talking about illegal/non-sensical formatting strings like "%lhd" or
even "%!!!!d" and similar.

The issue you raise is valid and important, but it is not for this bikeshed ;-)

Poul-Henning

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.


More information about the freebsd-arch mailing list