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]
Other format: [Raw text]

Re: typeof and bitfields


"Dave Korn" <dave.korn@artimi.com> writes:

| > -----Original Message-----
| > From: gcc-owner On Behalf Of Ian Lance Taylor
| > Sent: 14 January 2005 03:03
| 
| > I think the right semantics are for typeof to return the underlying
| > type, whatever it is, usually int or unsigned int.  Perhaps just
| > return make_[un]signed_type on the size of the mode of the bitfield,
| > or something along those lines.
| > 
| > If we implement that, and document it, I think it will follow the
| > principle of least surprise.
| > 
| > I don't see how giving an error is helpful.
| > 
| > Ian
| 
|   That seems _really_ wrong to me.
| 
|   If typeof (x) returns int, then I ought to be able to store INT_MAX in there
| and get it back, shouldn't I?  Otherwise, why not return typeof(char)==int as
| well?  They've got the same 'underlying type' too; they differ only in size;
| there's no reason to treat bitfields and chars differently.

That is an argument for not returning an int.  It is not an argument
for issueing error.  Why not return int_with_2bits?

-- Gaby


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