On Fri, Dec 5, 2025 at 11:09 AM Tom Lane <[email protected]> wrote:
> Apparently, latest gcc is able to notice that constructions like
>
>         const char *str = ...;
>         char       *ptr = strchr(str, ':');
>
> are effectively casting away const.  This is a good thing and long
> overdue, but we have some work to do to clean up the places where
> we are doing that.

Yeah, one of the qualifier-preserving generic functions that C23
invented: bsearch, memchr, strchr, strpbrk, strrchr, strstr, wcschr,
wcspbrk, wcsrchr, wmemchr, and wcsstr.  The synopses use QVoid or
QChar to mean "same qualifier", a bit like C++ function templates.  We
could probably benefit from some of that in our own code node, list,
tree etc code, as it only requires C11 _Generic to implement.

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf


Reply via email to