Hi,

>From a quick test with tcc, it looks like the
bitfield will be allocated the last 16 bits of
the struct.  When accessing it, tcc generates code
that loads a full 'unsigned int', hence loading
(or writing) 2 bytes after the end of the struct.

Not sure if that answers the question.

By the way, I use bitfields pretty extensively in
my compiler (https://c9x.me/compile/), and it looks
like C99 compound literals are not quite working
yet with those.  For example, the following program
fails to compile:

struct S {
        int x: 2;
        int y: 30;
};

int f()
{
        struct S x = {1, 2};
        return (struct S[]){x, {0, 0}}[1].y;
}

Best,

-- 
Quentin

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to