This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Regression with printf 8-bit format macros


Hello,

It appears to me that commit "Fix for pri and scn formats" [1] broke
the 8-bit printf format macros (PRI*8), for scenarios when newlib is
configured either with --enable-newlib-nano-formatted-io or without
--enable-newlib-io-c99-format is not used. Because the new code
defines these macros to the "hh" formats, which are not supported
then.

I think the code should be changed so that the PRI*8 macros are
defined correctly even when printf does not support hh. The previous
definitions of these format macros didn't have length modifiers (they
were just i, d, x, X, etc.) and seemed to have worked, presumably due
to default-promotion of int8_t/uint8_t to int. The way I understand
the standard, it is not correct to e.g. use PRId8 but pass to printf
something which is not an int8, so it shouldn't be a problem that e.g.
printf("%"PRId8, 1000) actually prints 1000; what matters is that it
prints all the possible int8_t values correctly when passed an int8_t.

[1] https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=892cfcb7c2fbdc3b2b09c95a7a6c2065e5e0cfae

Best regards,
Ambroz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]