Re: More const-marking cleanup

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: More const-marking cleanup
Date: 2025-12-04 22:52:35
Message-ID: CA+hUKGKg3Xc0EPDdz12SrnhVZ3Srnb=6TYTCScZWfFPZkZ24UQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 5, 2025 at 11:09 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2025-12-04 23:00:10 Re: [Proposal] Adding callback support for custom statistics kinds
Previous Message Mihail Nikalayeu 2025-12-04 22:35:00 Re: making tid and HOTness of UPDATE available to logical decoding plugins