STINNER Victor <vstin...@python.org> added the comment:
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}, ... }; ---- ---------- nosy: +gregory.p.smith _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46913> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com