On Mon, 23 Feb 2026, Bruno Haible wrote:

> Oh, I see now what you mean: In ISO C, any function call that takes
> a 'char *' argument can also take a 'void *' argument. In his definition
> of __glibc_const_generic, Joseph simulated this behaviour by explicitly
> allowing 'void *' and 'const void *' arguments, in all const-generic
> macros. I withdraw the claim it's a glibc bug; this choice makes perfect
> sense (for backward compatibility with older glibc versions where strchr
> was a plain function).

And, in addition, the type-generic macros can take a null pointer constant 
argument (of any type valid for a null pointer constant - void * or 
integer type or nullptr_t), as that is also valid for implicit conversion 
to const char *.  There are explicit footnotes in the standard about this 
case.  (For many of the functions it's undefined behavior if the call with 
a null argument gets executed, but it might still appear in the source 
code through use of macros.)

-- 
Joseph S. Myers
[email protected]


Reply via email to