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


Neil Booth <neil@daikokuya.co.uk> writes:

> Matt Austern wrote:-
> 
> > I'm finding this discussion a little frustrating because I think there 
> > is a good argument removing typeof for bit-field types but I haven't 
> > seen that argument yet.  I've seen a sort of summary of what that 
> > argument might be, and I'm trying to fill in the gaps.
> 
> Were the semantics of typeof on bitfields documented?  It raises all
> kinds of questions.  Such as do you get an integer type of a few bits,
> or the declared type?  What if the declared type is int but the bitfield
> has type unsigned int?
> 
> I think you need to decide semantics first.

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


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