Re: More const-marking cleanup - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: More const-marking cleanup
Date
Msg-id CA+hUKGKg3Xc0EPDdz12SrnhVZ3Srnb=6TYTCScZWfFPZkZ24UQ@mail.gmail.com
Whole thread Raw
In response to More const-marking cleanup  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Fri, Dec 5, 2025 at 11:09 AM Tom Lane <tgl@sss.pgh.pa.us> 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



pgsql-hackers by date:

Previous
From: Mihail Nikalayeu
Date:
Subject: Re: making tid and HOTness of UPDATE available to logical decoding plugins
Next
From: Sami Imseih
Date:
Subject: Re: [Proposal] Adding callback support for custom statistics kinds