New submission from Sam Price <thesampr...@gmail.com>:

if 8 1 byte fields are included in a ctype field, it allows an extra byte to be 
included in the packing when there is no room left for the next field.

If I put the bitfields in a child structure then I get expected results.
 
In [35]: run ctypeSizeTest.py
Size is  4 Expected 3
0 0x10000 a0
0 0x10001 a1
0 0x10002 a2
0 0x10003 a3
0 0x10004 a4
0 0x10005 a5
0 0x10006 a6
0 0x10007 a7
0 0x40008 b0 <- Expected to be at offset 1, not 0.
2 0xc0000 b1 <- Expected to be at offset 1, not 2
Size is  3 Expected 3
0 0x1 a
1 0x40000 b0
1 0xc0004 b1

----------
components: ctypes
files: ctypeSizeTest.py
messages: 363417
nosy: thesamprice
priority: normal
severity: normal
status: open
title: bitfield layout wrong in ctypes
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6
Added file: https://bugs.python.org/file48954/ctypeSizeTest.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39858>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to