Issue #82 resolved

Bitfield layout

Armin Rigo
created an issue

The exact bitfield layout is done in an approximative "seems to work" manner right now, but it doesn't work in all cases. See:

http://gcc.gnu.org/onlinedocs/gccint/Storage-Layout.html#index-PCC_005fBITFIELD_005fTYPE_005fMATTERS-3901

Comments (2)

  1. Armin Rigo reporter

    For reference: PCC_BITFIELD_TYPE_MATTERS seems to be True, at least on Linux32/64.

    Examples:

    struct foo2 { char x; int z:9; char y; }; => size 4

    struct foo2 { char x; short z:9; char y; }; => size 6

    struct foo3 { char x; int z:1; char y; }; => size 4

    struct foo3 { char x; int :1; char y; }; => size 3

    struct foo2 { char x; int :0; char y; }; => total length 5 (not aligned) but y is at 4 (aligned)

    struct foo2 { char x; long long :48; char y; }; => size 8

    struct foo2 { char x; long long :56; char y; }; => size 9

    struct foo2 { char x; long long :57; char y; }; => size 13/17 (on 32/64 bits)

    struct foo2 { char x; long long :0; char y; }; => size 5/9 (on 32/64 bits)

  2. Log in to comment