Sam Price <thesampr...@gmail.com> added the comment:

I ran into this bug on mac and submitted a duplicate issue of 39858


If you add the check *pfield_size != *pbitofs it fixes this bug.

#ifndef MS_WIN32
    } else if (bitsize /* this is a bitfield request */
        && *pfield_size /* we have a bitfield open */
        && *pfield_size != *pbitofs /* Current field has been filled, start new 
one */
        && dict->size * 8 >= *pfield_size
        && (*pbitofs + bitsize) <= dict->size * 8) {
        /* expand bit field */
        fieldtype = EXPAND_BITFIELD;
#endif


However this would not fix the results where you expand a bitfield around 3 
bytes.
clang produces the 3 bytes if you try and expand around.
#include <stdint.h>
#include <stdio.h>
typedef struct testA{
    uint8_t a0 : 7;
    uint8_t a1 : 7;
    uint8_t a2 : 7;
    uint8_t a3 : 3;
}  __attribute__((packed)) testA;

int main(){
    printf("%d\n", sizeof(testA)); /* Prints out 3 */
    return 0;
}
python prints out a size of 4.

----------
nosy: +thesamprice

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

Reply via email to