Re: More const-marking cleanup

Поиск
Список
Период
Сортировка
От Thomas Munro
Тема Re: More const-marking cleanup
Дата
Msg-id CA+hUKGKg3Xc0EPDdz12SrnhVZ3Srnb=6TYTCScZWfFPZkZ24UQ@mail.gmail.com
обсуждение исходный текст
Ответ на More const-marking cleanup  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления: