From mboxrd@z Thu Jan 1 00:00:00 1970 From: "David A. Greene" To: "Martin v. Loewis" Cc: greened@zip.eecs.umich.edu, egcs@egcs.cygnus.com Subject: Re: egcs and bitfields Date: Wed, 31 Mar 1999 23:46:00 -0000 Message-ID: <36E9614E.46596FEC@eecs.umich.edu> References: <36E844B2.8DAEFAAF@eecs.umich.edu> <199903112300.AAA19947@mira.isdn.cs.tu-berlin.de> <36E92F61.5951621@eecs.umich.edu> <199903121718.SAA09252@mira.isdn.cs.tu-berlin.de> X-SW-Source: 1999-03n/msg00468.html Message-ID: <19990331234600.10P_bRDD9CyUwzx9KCRVJWMDnpJr0ZixR0HaeBo6PpM@z> Martin v. Loewis wrote: > Ok, I can reproduce this printing -1. Yet, it still took me a while to > understand the problem. If you had provided proper references and > quotes, that would have been nice... Here's what I found: I apologize for that. I was under the impression that there was one "i386 System V ABI." As a lowly student I sort of assumed an ABI was a well-defined standard that specified interfaces between object code. Guess I was wrong. > The C standard explicitly leaves it unspecified whether an int > bitfield is signed or unsigned. In draft C9x, 6.7.2/5 says Exactly. This is C. > Now, the gcc documentation says, in the command-line-flags section, > > `-fsigned-bitfields' > `-funsigned-bitfields' > `-fno-signed-bitfields' > `-fno-unsigned-bitfields' > These options control whether a bitfield is signed or unsigned, > when the declaration does not use either `signed' or `unsigned'. > By default, such a bitfield is signed, because this is consistent: > the basic integer types such as `int' are signed types. > > However, when `-traditional' is used, bitfields are all unsigned > no matter what. Ok, I missed this completely. My fault for not looking at the docs. I never thought there would be flags for this, as it seems to me that you'd want a compiler to adhere to a standard interface. > Please have a look at the section 'Non-bugs' in the GCC manual. It > explains, in an elaborate way, why things are the way they are (and > yes, I've read this section for the first time today :-) :) Ok, I'll have a look...a good bit of reading, that. It answers a lot of questions, even if I don't agree with those answers. :) Thanks! -Dave