[cfe-commits] r54395 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGen/2008-07-22-packed-bitfield-access.c

Eli Friedman eli.friedman at gmail.com
Mon Aug 18 17:10:57 PDT 2008

On Sat, Aug 9, 2008 at 7:38 PM, Daniel Dunbar <daniel at zuster.org> wrote:
> Yes, I actually looked at that while implementing the code. I assume
> you meant padded instead of aligned.

Yes... although, alignment is the only way to get implicit padding in structs.

> Is this a case we really care about supporting? It is not immediately clear
> to me that
>   struct __attribute((packed)) x {int a : 24;};
> shouldn't have size sizeof(int) instead of size 3. There is a difference between
> the packing of the bitfield and the size of the structure. Is this a case which
> matters in practice?

Per gcc, it has size 3, so we should honor that.  This bug would only
be exposed by programs very rarely, but that isn't an excuse for
generating wrong code.

Although, I guess it can wait until we add alignment to lvalues;
currently, codegen basically don't handle misaligned fields at all.


More information about the cfe-commits mailing list