egcs and bitfields

Doug Semler doug@seaspace.com
Fri Mar 12 09:41:00 GMT 1999


> > #include <stdio.h>
> > 
> > struct foo { int c:3; } x = { 7 };
> > 
> > int main(void)
> > {
> >   printf("%d\n", x.c);
> > 
> >   return(0);
> > }
> > 
> > >>-drakh-> egcc fieldinit.c
> > >>-drakh-> ./a.out
> > -1
> > 
> > I think the output should be 7, since an "int"
> >  bitfield is supposed
> > to be unsigned according to the i386 SysV ABI.
> 
> While I can't comment on any correctness issues in the example or
> pertinence of various ABI specs, I can confirm that your example behaves
> differently on different System V/386's.
> 
> 
> On OpenServer: 
> 	/bin/cc		-1
> 	egcs 1.1.1 	-1
> 	icc		7
> 	udk cc		7 
> 
> On UnixWare 7.0.1
> 	/bin/cc		7
> 	egcs 1.1.1 	-1
> 
> 
> Note that /bin/cc on SVR5 is essentially the same as UDK on OSR5.  Since
> /bin/cc on OpenServer had parentage in the code that became those two 
> compilers, I'm guessing that it was an intentional ABI change between
> the OpenServer lineage (more iBCS2-ish) and the SVR4 lineage.

I am assuming egcs uses the ABI's definition of whether a bitfield is
signed or unsigned????   According to the standard (6.7.2) unqualified
type int is implementation defined (cf C++ 9.6)

So, does egcs use the same implementation across all platforms?

---
Doug Semler                       | doug@seaspace.com
SeaSpace Corporation              | Garbage In -- Gospel Out
Least Senior Software Developer;  | Minister of things to do Next Quarter
Low Man on the Totem Pole         | (but will Never Be Done) DNRC  O-
A closed mind is a terrible thing | Bus Error (passengers dumped)
  
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/M d---(pu) s++:- a-- C++ UILSH+++$ P--- L++ E--- W+
N++ o-- K? w--(++$) O- M-- V- PS+ !PE Y PGP t(+) 5+++ X+
R- tv+(-) b+(++) DI++++ D G e++>++++ h!>--- r% y+>+++++**
------END GEEK CODE BLOCK------





More information about the Gcc mailing list