-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
GH-131296: fix clang-cl warning on Windows in longobject.c for 32bit builds #131604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Objects/longobject.c
Outdated
@@ -909,7 +909,9 @@ _PyLong_NumBits(PyObject *vv) | |||
assert(ndigits == 0 || v->long_value.ob_digit[ndigits - 1] != 0); | |||
if (ndigits > 0) { | |||
digit msd = v->long_value.ob_digit[ndigits - 1]; | |||
#if SIZEOF_SIZE_T > 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix warning : result of comparison of constant 307445734561825860 with expression of type 'Py_ssize_t' (aka 'int') is always true [-Wtautological-constant-out-of-range-compare]
FTR: this is a general 32bit warning and not only related to 32bit clang-cl builds on Windows, see e.g. ARM Raspbian PR.
warning: comparison is always true due to limited range of data type [-Wtype-limits]
Interesting, that clang already emits this with no warning level given, but GCC only with -Wextra
(which is used in Python builds anyway): https://godbolt.org/z/d3r4sP1q3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could rather use SIZEOF_SIZE_T == 8
as test.
Yeah, I think there exist no platforms with |
I doubt, maybe only for some (unknown) processor with 128-bit byte addressing. |
Changed to |
FTR, if we were to assume that SIZEOF_SIZE_T != 4 or 8, we would have some pretty bad surprises elsewhere: Strings and codecs:cpython/Objects/stringlib/find_max_char.h Lines 10 to 16 in 5707837
cpython/Objects/stringlib/codecs.h Lines 11 to 17 in 5707837
Free-threaded build:Lines 355 to 365 in 5707837
Windows in general:Lines 342 to 377 in 5707837
There are other places where we check for sizeof(size_t) == 4 or 8, even in |
Yeah, I know. Didn't want to introduce more of them, but I am fine either way :) And there are two So many ways to skin that cat 🚀 |
Does this one need a backport? |
So far, non of the warnings I've fixed due to clang-cl have been backported. None of them was hard, though, but mostly, because many (all?) of them were clang-cl / Windows specific - and clang-cl is an unsupported compiler #131296 (comment):
Maybe I've missed to mark some of them when the warning was not specific to only this combination, but here I noticed. So indeed, this one could be packported, since it affects other platforms / compilers, too. Whether that should be done I'm not experienced enough to answer. My gut feeling: +0 |
I think I said "no backports" if those warnings were actually non-fatal, but here isn't it possible for the assertion to actually fail on some debug builds? if so it's better to backport it. |
The assert won't fire, the warning is actually about that it will never fire on 32bit debug builds:
It's really just to silence the warning, so maybe no backport then? Unless we'd like to treat the warning as a bug, like Gregory said in #131296 (comment)
|
Oh ok! so no backport then. We can only backport stuff to 3.13 now so I don't think it's worth it. Let's only backport stuff if there can be issues at runtime. |
I think this is a skip news?