Fix some strchr (discarded) qualifier issues with C23
Mark Wielaard
mark@klomp.org
Sat May 2 16:56:50 GMT 2026
GCC 16.1 defaults to C23 and glibc 2.43 added const qualifiers to
serveral functions. In particular strchr will now return a const char
* when a const char * is given as input (and a char * when given a
char * as input).
This results in errors like:
eaarch64pe.c: In function ‘gldaarch64pe_after_open’:
eaarch64pe.c:1689:17: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
1689 | pnt = strrchr (bfd_get_filename (is->the_bfd), '.');
| ^
[PATCH 1/2] gprof: Fix strchr discarded qualifier call
[PATCH 2/2] ld: Fix calls to strchr that discard or use wrong const
More information about the Binutils
mailing list