Building with GCC 15 produces warnings for usage of C23 qualifier-generic
functions like strchr/strrchr, e.g.:
pathexp.c: In function ‘glob_name_is_acceptable’:
pathexp.c:533:5: warning: assignment discards ‘const’ qualifier from
pointer target type [-Wdiscarded-qualifiers]
533 | n = strrchr (name, '/');
| ^
See [1] for similar changes to gnulib.
[1] https://lists.gnu.org/r/bug-gnulib/2025-11/msg00220.html
---
builtins/getopt.c | 3 ++-
examples/loadables/seq.c | 2 +-
lib/sh/mbschr.c | 2 +-
lib/sh/utf8.c | 2 +-
pathexp.c | 2 +-
5 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/builtins/getopt.c b/builtins/getopt.c
index 47a8f77c..283de6a0 100644
--- a/builtins/getopt.c
+++ b/builtins/getopt.c
@@ -113,7 +113,8 @@ int sh_badopt = 0;
int
sh_getopt (int argc, char *const *argv, const char *optstring)
{
- char c, *temp;
+ char c;
+ const char *temp;
sh_optarg = 0;
diff --git a/examples/loadables/seq.c b/examples/loadables/seq.c
index 13834b8d..89517c1d 100644
--- a/examples/loadables/seq.c
+++ b/examples/loadables/seq.c
@@ -171,7 +171,7 @@ static int
getprec (const char *numbuf)
{
int p;
- char *dp;
+ const char *dp;
if (dp = strchr (numbuf, decimal_point))
dp++; /* skip over decimal point */
diff --git a/lib/sh/mbschr.c b/lib/sh/mbschr.c
index f86ea0bb..4d24eb65 100644
--- a/lib/sh/mbschr.c
+++ b/lib/sh/mbschr.c
@@ -81,5 +81,5 @@ mbschr (const char *s, int c)
}
else
#endif
- return (strchr (s, c));
+ return (char *) strchr (s, c);
}
diff --git a/lib/sh/utf8.c b/lib/sh/utf8.c
index c5503301..2d1abf30 100644
--- a/lib/sh/utf8.c
+++ b/lib/sh/utf8.c
@@ -35,7 +35,7 @@ extern int locale_utf8locale;
char *
utf8_mbschr (const char *s, int c)
{
- return strchr (s, c); /* for now */
+ return (char *) strchr (s, c); /* for now */
}
int
diff --git a/pathexp.c b/pathexp.c
index 87c49bf3..dc0f375d 100644
--- a/pathexp.c
+++ b/pathexp.c
@@ -525,7 +525,7 @@ static int
glob_name_is_acceptable (const char *name)
{
struct ign *p;
- char *n;
+ const char *n;
int flags;
/* . and .. are never matched. We extend this to the terminal component of a
--
2.54.0