question on conversion specification implemented in newlib

Eric Blake
Wed May 9 13:43:00 GMT 2012

On 05/08/2012 03:20 AM, Can Finner wrote:
> Hi,
> I noticed that there is below sentence in C standard:
> Each conversion specification is introduced by the character %. After

Wow - I've never seen copy-and-paste insert 'fi' as a single UTF-8
ligature character before.

> the %, the following
> appear in sequence:
> — Zero or more flags (in any order)
> — An optional minimum field width.
> — An optional precision
> — An optional length modifier
> — A conversion specifier character
> As quotes, the five kinds of character should appear in sequence, so
> it is undefined
> behavior if they are not in sequence?
> I noticed that following codes works fine with newlib,
> fprintf(stdout, "%*.*-d\n", 100, 10, 32);

This is unspecified behavior, so anything can happen.  It would be nicer
if fprintf failed with EINVAL, but that is not a requirement.

> Any help? Thanks.

What help are you looking for?  Confirmation that your code is
unspecified, and that you got lucky that it happened to do what you
wanted?  A request to change newlib to behave the same as glibc?

Eric Blake    +1-919-301-3266
Libvirt virtualization library

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the Newlib mailing list