This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: egcs and bitfields
> struct baz { unsigned int a:2, b:4, c:32;} y;
>
> void foo()
> {
> y.c = 0x56789;
> }
>
> int main()
> {
> unsigned int *b;
> bzero(&y,sizeof(y));
> foo();
> b=&y;
> printf("%x %x\n",b[0],b[1]);
> }
>
> Is this the case you are talking about? Now, you claim that the SysV
> ABI requires y.c to be at offset 4, right? (this is a claim I can't
> verify since I don't have that specification)
"System V ABI" is too vague for purposes of this discussion. Do you
refer to the iBCS2 spec or the SVR4 ABI? I don't know that they differ
in this regard, but it isn't an unreasonable question before tearing
into large books.
> Anyway, when I run the program on i586-pc-linux-gnu, with
> egcs-2.93.11, I get as output
>
> 0 56789
>
> From your explanation, I understand that this result is
> ABI-compliant. So where is the problem?
I fed this example into the following compilers on a system V/386 host:
SCO OpenServer /bin/cc
UDK cc (essentially the SVR4 ABI)
EGCS 1.1.1
Intel's optimizing compiler
It produced identical output on all of them.
I think (but am no authority) that Linux uses substantially the SVR4 ABI
but it does have some deviations.
RJL