[PATCH v3] Implement C23 const-preserving standard library macros

Paul Eggert eggert@cs.ucla.edu
Wed Nov 19 21:28:19 GMT 2025


On 2025-11-19 12:56, Joseph Myers wrote:
> +In ISO C23 and later, if the expression passed as @var{array} has a
> +type that is a pointer to a @code{const}-qualified type,
> +@code{bsearch} returns @code{const void *}.

This is true for the macro but not the function, right? And there is 
obsolescent backward-compatibility if you #undef the macro. So I suggest 
rewording this to something like the following:

In ISO C23 and later, this function is qualifier-generic:
that is, it is also implemented as a function-like macro,
and when the macro is used and @var{array} has a type
that is a pointer to a @code{const}-qualified object type,
@code{bsearch} returns @code{const void *}.
As an obsolescent feature, if the macro is suppressed
the external function returns @code{void *} regardless.

... and similarly for the other functions. Or perhaps you can think of a 
more-concise way to say it.


More information about the Libc-alpha mailing list