Skip to content

Commit 4646873

Browse files
authored
[FRONTEND] Fix PyFloat_Pack2 casting (#7487)
Fix issue found by @anmyachev at triton-lang/triton#7439 > Should it be like: `_PyFloat_Pack2(f, (unsigned char *)&result, 1);`? (this is how it is implemented in https://github.com/python/pythoncapi-compat/blob/b541b98df1e3e5aabb5def27422a75c876f5a88a/pythoncapi_compat.h#L488) > > I see the following issue with current approach: > > ```shell > python/test/unit/language/test_annotations.py /tmp/tmp9qfrehja/main.cpp:148:5: error: no matching function for call to '_PyFloat_Pack2' > 148 | _PyFloat_Pack2(f, (void*)&result, 1); > | ^~~~~~~~~~~~~~ > /home/jovyan/.conda/envs/xpu/include/python3.10/floatobject.h:87:17: note: candidate function not viable: cannot convert argument of incomplete type 'void *' to > 'unsigned char *' for 2nd argument > 87 | PyAPI_FUNC(int) _PyFloat_Pack2(double x, unsigned char *p, int le); > | ^ ~~~~~~~~~~~~~~~~ > 1 error generated. > ```
1 parent de9309d commit 4646873

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

third_party/amd/backend/driver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,9 @@ def format_of(ty):
470470
uint16_t result;
471471
// from https://github.com/python/pythoncapi-compat
472472
#if 0x030600B1 <= PY_VERSION_HEX && PY_VERSION_HEX <= 0x030B00A1 && !defined(PYPY_VERSION)
473-
_PyFloat_Pack2(f, (void*)&result, 1);
473+
_PyFloat_Pack2(f, (unsigned char*)&result, 1);
474474
#else
475-
PyFloat_Pack2(f, (void*)&result, 1);
475+
PyFloat_Pack2(f, (unsigned char*)&result, 1);
476476
#endif
477477
return result;
478478
}}

third_party/nvidia/backend/driver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,9 @@ def format_of(ty):
475475
uint16_t result;
476476
// from https://github.com/python/pythoncapi-compat
477477
#if 0x030600B1 <= PY_VERSION_HEX && PY_VERSION_HEX <= 0x030B00A1 && !defined(PYPY_VERSION)
478-
_PyFloat_Pack2(f, (void*)&result, 1);
478+
_PyFloat_Pack2(f, (unsigned char*)&result, 1);
479479
#else
480-
PyFloat_Pack2(f, (void*)&result, 1);
480+
PyFloat_Pack2(f, (unsigned char*)&result, 1);
481481
#endif
482482
return result;
483483
}}

0 commit comments

Comments
 (0)