Repository navigation
Conversation
Py_MIN, Py_MAX, and Py_ABSPy_MIN, Py_MAX, and Py_ABS
ZeroIntensity
left a comment
There was a problem hiding this comment.
It's not clear to me that this is the right fix. We should first try to fix the macros, not just jump to reverting #157496.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
To me it's the only possible fix. We can't have issues for: /* bitfield.c: compile with -c */
#include <Python.h>
struct S { unsigned bf : 4; };
int f(struct S *s, int k) { return Py_MAX(s->bf, k); }this specific one: and the correctness issue here is concerning: /* wrong_result.c */
#include <Python.h>
#include <stdio.h>
int main(void)
{
int a = 1, _x = 5;
printf("Py_MAX(a, _x) = %d (expected 5)\n", Py_MAX(a, _x));
int b = 9, _y = 2;
printf("Py_MIN(b, _y) = %d (expected 2)\n", Py_MIN(b, _y));
int c = -7;
{
int _x = c;
printf("Py_ABS(_x) = %d (expected 7)\n", Py_ABS(_x));
}
return 0;
}Note: I didn't run the code but having different (wrong) results depending on -O flag and compiler is really not good. |
|
I will merge #158969 instead, PR which should fix most issues that you reported. |
Py_MIN(),Py_MAX()andPy_ABS()cause C compatibility regressions #158942