This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author thesamprice
Recipients Charles Machalow, amaury.forgeotdarc, belopolsky, eryksun, karlding, meador.inge, mleroy003, shihai1991, thesamprice, ztane
Date 2020-03-05.16:19:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1583425159.02.0.416151613526.issue29753@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-03-05 16:19:19thesampricesetrecipients: + thesamprice, amaury.forgeotdarc, belopolsky, meador.inge, eryksun, ztane, Charles Machalow, mleroy003, shihai1991, karlding
2020-03-05 16:19:19thesampricesetmessageid: <1583425159.02.0.416151613526.issue29753@roundup.psfhosted.org>
2020-03-05 16:19:18thesampricelinkissue29753 messages
2020-03-05 16:19:18thesampricecreate