EGCS 2.91.66 Bug: sizeof() + struct problem (char == and != int)

Martin v. Loewis
Thu Sep 30 19:57:00 GMT 1999

> I get this output:
> ---------------------------------------------------------------------------
> sizeof=12
> sizeof=12
> 1 -- 2 -- 4
> ---------------------------------------------------------------------------
> whereas I had expected it to be 10 and 7 !!

Thanks for your bug report. I fail to see the bug in it, though - you
did not say *why* you expected these results, and why you think that
any other results are wrong.

Anyway, there is a good reason for it: The compiler aligns fields
according to their "alignment requirements". You can find out more
about alignment in a number of documents:
- the ISO C standard,
- documentation about the Intel 386 processor, 
- definition of the Unix ABI on Intel, and
- the GCC documentation.

As a result of alignment, the compiler inserts "padding" between
fields. *Not* doing so would be a bug, as it would break binary

Hope this helps,

More information about the Gcc-bugs mailing list