Skip to content

Commit a8f66c0

Browse files
committed
gh-145094: fix discards const qualifier from pointer
Since glibc-2.43 and 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. candidate * pointer returns are only being used for comparisons so declare them as const, which matches the input variables.
1 parent 2be2dd5 commit a8f66c0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Objects/stringlib/fastsearch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ STRINGLIB(find_char)(const STRINGLIB_CHAR* s, Py_ssize_t n, STRINGLIB_CHAR ch)
6969
and UCS4 representations. */
7070
if (needle != 0) {
7171
do {
72-
void *candidate = memchr(p, needle,
73-
(e - p) * sizeof(STRINGLIB_CHAR));
72+
const void *candidate = memchr(p, needle,
73+
(e - p) * sizeof(STRINGLIB_CHAR));
7474
if (candidate == NULL)
7575
return -1;
7676
s1 = p;

0 commit comments

Comments
 (0)