Fix a warning with gcc 15 and glibc 2.43
Bruno Haible via Bug reports for the GNU Texinfo documentation system <[email protected]>
| Newsgroups | gmane.comp.tex.texinfo.bugs |
|---|---|
| Organization | GNU |
| Message-ID | <32173302.2dzg3u6YtW@nimes> |
Building texinfo-7.2.90 with gcc 15.2.0 and glibc 2.43 (that was released
yesterday), I see a warning:
../../install-info/install-info.c:1605:15: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
The cause is this change in glibc [1]:
* For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr,
strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return
pointers into their input arrays now have definitions as macros that
return a pointer to a const-qualified type when the input argument is
a pointer to a const-qualified type.
Here, ISO C 23 wants 'ptr' to be a 'const char *', not a 'char *'.
And with it, 'endptr' must be of the same type as well.
Find attached a proposed patch. I have verified that it fixes the warning.
[1] https://lists.gnu.org/archive/html/info-gnu/2026-01/msg00005.html
0001-install-info-Fix-warning-with-gcc-15-and-glibc-2.43.patch
(text/x-patch, 1.2 KB)
From 053706be2cd2de3c3356307e637b84458fa63078 Mon Sep 17 00:00:00 2001 From: Bruno Haible <[email protected]> Date: Sun, 25 Jan 2026 02:32:01 +0100 Subject: [PATCH] install-info: Fix warning with gcc 15 and glibc 2.43. * install-info/install-info.c (split_entry): Change type of ptr and endptr to conform to ISO C 23. --- install-info/install-info.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install-info/install-info.c b/install-info/install-info.c index c690e01470..2fa2ecca99 100644 --- a/install-info/install-info.c +++ b/install-info/install-info.c @@ -1596,13 +1596,13 @@ static void split_entry (const char *entry, char **name, size_t *name_len, char **description, size_t *description_len) { - char *endptr; + const char *endptr; /* on the first line, the description starts after the first ". "; that's a period and space -- our heuristic to handle item names like "config.status", and node names like "config.status Invocation". Also accept period-tab and period-newline. */ - char *ptr = strchr (entry, '.'); + const char *ptr = strchr (entry, '.'); while (ptr && ptr[1] != ' ' && ptr[1] != '\t' && ptr[1] != '\n') { ptr = strchr (ptr + 1, '.'); } -- 2.52.0