This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: egcs and bitfields


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]