standards/65779: Potential bug in printf positional parameters

Wartan Hachaturow wart at tepkom.ru
Mon Apr 19 13:40:26 PDT 2004


The following reply was made to PR standards/65779; it has been noted by GNATS.

From: Wartan Hachaturow <wart at tepkom.ru>
To: freebsd-gnats-submit at FreeBSD.ORG
Cc:  
Subject: Re: standards/65779: Potential bug in printf positional parameters
Date: Tue, 20 Apr 2004 00:28:06 +0400

 (sorry, misspelled gnats address in the last letter)
 
 On Mon, Apr 19, 2004 at 03:18:47PM -0400, Jonathan McGee wrote:
 
 > A minimum test case was written and attached (test-libc.c).  When built, four
 > integers (1, 2, 3, 4) are passed to a positional printf that should display
 > them in order, skipping the second.
 
 This is not a bug.
 To quote SUSv3
 (http://www.opengroup.org/onlinepubs/007904975/functions/fprintf.html):
 
 "When numbered argument specifications are used, specifying the Nth
 argument requires that all the leading arguments, from the first to the
 (N-1)th, are specified in the format string."
 
 Furthemore, man 3 printf says:
 
 "Arguments are numbered starting at 1.  If unaccessed arguments
  in the format string are interspersed with ones that are accessed 
  the results will be indeterminate."
 
 .. which is just what you get.
 
 -- 
 Regards, Wartan.
 "Be different: conform."


More information about the freebsd-standards mailing list