On Sat, 29 Jun 2019, Segher Boessenkool wrote: > So I'd say that yes, void * and char * are interchangeable as arguments > to variable argument functions as well.
They are explicitly interchangeable as arguments to variable argument functions using va_arg; the definition of va_arg specifies that "one type is a signed integer type, the other type is the corresponding unsigned integer type, and the value is representable in both types" and "one type is pointer to void and the other is a pointer to a character type" are both allowed. So this is one of those questions about whether printf is required to behave as if implemented in C using va_arg, or whether the specification of argument types to printf being stricter than what's allowed for va_arg imposes extra requirements on callers of printf. This is where gcc.dg/format/c90-printf-1.c has the comment /* With -pedantic, we want some further checks for pointer targets: %p should allow only pointers to void (possibly qualified) and to character types (possibly qualified), but not function pointers or pointers to other types. (Whether, in fact, character types are allowed here is unclear; see thread on comp.std.c, July 2000 for discussion of the requirements of rules on identical representation, and of the application of the as if rule with the new va_arg allowances in C99 to printf.) Likewise, we should warn if pointer targets differ in signedness, except in some circumstances for character pointers. (In C99 we should consider warning for char * or unsigned char * being passed to %hhn, even if strictly legitimate by the standard.) */ [...] /* Allow character pointers with %p. */ printf ("%p%p%p%p", s, ss, us, css); -- Joseph S. Myers jos...@codesourcery.com