Make <inttypes.h> printf macros narrow arguments (bug 31470)
Collin Funk
collin.funk1@gmail.com
Fri Oct 17 22:30:18 GMT 2025
Joseph Myers <josmyers@redhat.com> writes:
> 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.
Looks good to me.
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
Thanks,
Collin
More information about the Libc-alpha
mailing list