[issue6493] Can not set value for structure members larger than 32 bits
Meador Inge
report at bugs.python.org
Thu Jul 19 06:36:36 CEST 2012
Meador Inge <meadori at gmail.com> added the comment:
The problem is with the 'BIT_MASK' macro, which is currently defined as the following for Windows:
#define BIT_MASK(size) ((1 << NUM_BITS(size))-1)
The C standard says that any attempt to shift left by exactly the bit width is undefined behavior. For the given test case 'NUM_BITS(size) == 32' and the '1' constant is of type 'int'. Thus the behavior is undefined.
For x86 Windows with the MSVC++ compiler this ends up as 'SAL edx, CL' and the Intel manuals say that the shift count is masked by 0x1F. Thus the bit mask ends up as '(1 << 0) - 1 == 0'. Plug the zero mask into the 'SET' macro and you will see why the reported behavior is being observed.
I tested Hirokazu's last patch on Windows 7 64-bit and OS X 10.7; I saw no regression. I will apply the patch shortly.
----------
assignee: -> meador.inge
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6493>
_______________________________________
More information about the Python-bugs-list
mailing list