-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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
New warning in the main (-Warray-bounds) #131820
Comments
I don't understand the warning, the function uses a pointer, it doesn't use an array: static inline void Py_DECREF_MORTAL(PyObject *op)
{
assert(!_Py_IsStaticImmortal(op));
_Py_DECREF_STAT_INC();
if (--op->ob_refcnt == 0) {
_Py_Dealloc(op);
}
} |
I think it has to do with the compiler performing the decrement on the |
IIRC, according to precedence rules |
I mean, this is a bug in the compiler, not in our code. I understand adding parens as a way of silencing certain warnings about unclear operator precedence for human readers, etc. But if the compiler just doesn't understand C operator precedence, it’s just incorrect and should be fixed in the compiler. |
This looks like a bug in GCC: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104828 It’s probably because this particular pointer is cast from an integer ( |
I guess it's screwing with the operator precedence somehow? |
No, I don’t think this has anything to do with operator precedence. It’s just the dereference ( Basically, as I understand it, the C compiler tries its best to keep track of what exactly you’re pointing to. Among other things, it can use this info to tell you if you’re out of bounds of an array, or if you’re accessing invalid memory. I think the “problem” is that when we cast the bits to a pointer (which is fine, tons of programs do it without issue), it’s sort of interpreting that as actually being a pointer to memory that doesn’t “exist” (similar to trying to access It’s a compiler bug, plain and simple. Looks like it’s been fixed, too. We should probably just close this as “won’t fix”. |
Bisected to 67fbfb4. I would appreciate a workaround, but if it's not actual for gcc 14 - probably this not worth it. It seems, there are no warnings on gcc-10: https://github.com/python/cpython/actions/runs/14139921809/job/39619432128 |
Bug report
Bug description:
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
The text was updated successfully, but these errors were encountered: