{{ message }}
gh-131296: Fix clang-cl warning on Windows in posixmodule.c - #133142
Merged
Conversation
auvipy
reviewed
Apr 29, 2025
auvipy
left a comment
There was a problem hiding this comment.
looks good. do we also need to update relevant test for this change?
Contributor
Author
chris-eibl
reviewed
Apr 30, 2025
chris-eibl
reviewed
May 2, 2025
| the space needed for the terminator. */ | ||
| if (len >= Py_ARRAY_LENGTH(wbuf)) { | ||
| if (len <= PY_SSIZE_T_MAX / sizeof(wchar_t)) { | ||
| if ((Py_ssize_t)len <= PY_SSIZE_T_MAX / sizeof(wchar_t)) { |
Member
There was a problem hiding this comment.
This indeed fixes the warning. IMHO, that's the most pragmatic fix. We could be fancy and do some #if on sizeof(Py_ssize_t), etc, but I don't think it is worth the hassle.
Member
There was a problem hiding this comment.
sizeof doesn't work in preprocessor checks anyway.
Member
There was a problem hiding this comment.
Yeah, I meant something like we do with SIZEOF_SIZE_T, but did not want to elaborate about it in great detail, because IMHO it isn't worth the churn?
chris-eibl
approved these changes
May 2, 2025
DangNhutNguyen
approved these changes
May 2, 2025
Contributor
Author
|
@zooba Could you review and merge it, thank you! |
Member
Pranjal095
pushed a commit
to Pranjal095/cpython
that referenced
this pull request
Jul 12, 2025
Clang-cl detects that on 32-bit builds the variable is always smaller than the value. But since the same code is used for other architectures, we can't just _fix_ it. This cast avoids the tautological-constant-out-of-range-compare warning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Only 1 warning in
posixmodule.cPlease add skip news label :)