Message414456
test_ctypes: test_shorts() of ctypes.test.test_bitfields.C_Test is failing with:
---
test_shorts (ctypes.test.test_bitfields.C_Test) ... /home/vstinner/python/main/Modules/_ctypes/cfield.c:554:5: runtime error: shift exponent 18446744073709551614 is too large for 16-bit type 'short'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/vstinner/python/main/Modules/_ctypes/cfield.c:554:5 in
---
It's a test on the "h" format code:
----
#define LOW_BIT(x) ((x) & 0xFFFF)
#define NUM_BITS(x) ((x) >> 16)
#define GET_BITFIELD(v, size) \
if (NUM_BITS(size)) { \
v <<= (sizeof(v)*8 - LOW_BIT(size) - NUM_BITS(size)); \
v >>= (sizeof(v)*8 - NUM_BITS(size)); \
static PyObject *
h_get(void *ptr, Py_ssize_t size)
{
short val;
memcpy(&val, ptr, sizeof(val));
GET_BITFIELD(val, size); // <==== HERE
return PyLong_FromLong((long)val);
}
static struct fielddesc formattable[] = {
...
{ 'h', h_set, h_get, NULL, h_set_sw, h_get_sw},
...
};
---- |
|
Date |
User |
Action |
Args |
2022-03-03 16:20:36 | vstinner | set | recipients:
+ vstinner, gregory.p.smith, pablogsal |
2022-03-03 16:20:36 | vstinner | set | messageid: <1646324436.55.0.146677749703.issue46913@roundup.psfhosted.org> |
2022-03-03 16:20:36 | vstinner | link | issue46913 messages |
2022-03-03 16:20:36 | vstinner | create | |
|