Skip to content

[3.13] gh-149707: Fix compiler warning in _ctypes_test on strchr() (GH-149791)#149864

Closed
miss-islington wants to merge 1 commit into
python:3.13from
miss-islington:backport-5465b69-3.13
Closed

[3.13] gh-149707: Fix compiler warning in _ctypes_test on strchr() (GH-149791)#149864
miss-islington wants to merge 1 commit into
python:3.13from
miss-islington:backport-5465b69-3.13

Conversation

@miss-islington
Copy link
Copy Markdown
Contributor

@miss-islington miss-islington commented May 15, 2026

Change my_strchr() return type to "const char*" (add "const").

Fix the compiler warning:

Modules/_ctypes/_ctypes_test.c: In function 'my_strchr':
Modules/_ctypes/_ctypes_test.c:451:12: warning: return discards
'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
451 | return strchr(s, c);
| ^~~~~~

When using C23, strchr(text, ch) return type is "const char*" if text
type is "const char*".
(cherry picked from commit 5465b69)

Co-authored-by: Victor Stinner vstinner@python.org

…thonGH-149791)

Change my_strchr() return type to "const char*" (add "const").

Fix the compiler warning:

Modules/_ctypes/_ctypes_test.c: In function 'my_strchr':
Modules/_ctypes/_ctypes_test.c:451:12: warning: return discards
'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  451 |     return strchr(s, c);
      |            ^~~~~~

When using C23, strchr(text, ch) return type is "const char*" if text
type is "const char*".
(cherry picked from commit 5465b69255890650df99debb8256e0a7bc68138b)

Co-authored-by: Victor Stinner <vstinner@python.org>
@vstinner
Copy link
Copy Markdown
Member

I backported the change manually since the bot had issues: #149867.

@vstinner vstinner closed this May 15, 2026
@miss-islington miss-islington deleted the backport-5465b69-3.13 branch May 15, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants