]> git.ipfire.org Git - thirdparty/glibc.git/commit
Make <inttypes.h> printf macros narrow arguments (bug 31470)
authorJoseph Myers <josmyers@redhat.com>
Mon, 20 Oct 2025 12:44:40 +0000 (12:44 +0000)
committerJoseph Myers <josmyers@redhat.com>
Mon, 20 Oct 2025 12:44:40 +0000 (12:44 +0000)
commit0807a262de1ecfb74cb1b8d14097176d2098a2cb
treef65bc12a861114924e481d947acca000a88150c0
parent0375e6e2336a779cdddb4d11442126d366b1efc2
Make <inttypes.h> printf macros narrow arguments (bug 31470)

A late change in C23, the resolution to CD2 comment GB-108, specified
that <inttypes.h> macros such as PRId8 expand to formats such that,
when an argument is passed in the promoted type that isn't
representable in the original type such as int8_t corresponding to the
format, it gets converted to that type before printing.  (Previously,
the proper handling of such arguments was unclear; the case of direct
use of formats such as %hhd was clarified earlier in C23 development,
and had been fixed in glibc in 2006.)  Implement the change to use
formats such as "hhd" for the affected macros, with associated tests.

Tested for x86_64 and x86.
stdio-common/Makefile
stdio-common/tst-printf-macro.c [new file with mode: 0644]
stdlib/inttypes.h