fprintf and fwprintfAuthors: Jay Ghiron
Date: 2026-10-29
Submitted against: C23
Status: Open
All conversion specifications mentioned here are applicable to both
fprintf and fwprintf. All other formatted output functions
reference one of these two functions.
For the conversion specifiers which take pointers, they use wording
such as "The argument shall be a pointer to void or a pointer to a
character type." (C23 7.23.6.2 "The fprintf function" paragraph 8.)
in their definitions. Does the use of shall here impose further
requirements on the arguments than is already required by va_arg?
For example, is it valid to pass an argument of type const void* to
%p? Additionally, va_arg(v,void*), va_arg(v,char*), and
va_arg(v,unsigned char*) are not all equivalent. With an enumerated
type such as enum E:char{e}; the type enum E* is only valid as the
type of an argument for va_arg(v,char*). Given that the definitions
of the conversion specifiers s (with no l length modifier) and p
avoid specifying a specific type it is unclear what type would be used
in the va_arg invocations for %s and %p.
Can flags be repeated? For example, is %##x valid for an
appropriate argument?
The flags + and space do not have any wording that requires them to
be used with specific conversion specifiers. For conversion
specifications that are not signed, does this cause undefined behavior
by omission or does it have no effect? For example, is %+c defined
or undefined? The flag - and field widths similarly have no
requirements, but it seems intended to allow them for any conversion
specifier.