bool bitfields

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

bool bitfields

Ted Kremenek-2
For "boolean" bitfields, we sometimes use "unsigned" and sometimes use "bool", e.g.:

$ grep ': 1;' *
...
Type.h:  bool SubClassData : 1;
...
Type.h:  unsigned NoReturn : 1;
...

I vaguely recall that we switched to using "unsigned" a while back for bitfields that were enums (I believe that enums are being treated as "signed" by Visual C++).  Since these are bools, not enum, what should we be doing here?  It would be nice to be consistent.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: bool bitfields

Douglas Gregor

On Sep 14, 2010, at 9:09 AM, Ted Kremenek wrote:

> For "boolean" bitfields, we sometimes use "unsigned" and sometimes use "bool", e.g.:
>
> $ grep ': 1;' *
> ...
> Type.h:  bool SubClassData : 1;
> ...
> Type.h:  unsigned NoReturn : 1;
> ...
>
> I vaguely recall that we switched to using "unsigned" a while back for bitfields that were enums (I believe that enums are being treated as "signed" by Visual C++).  Since these are bools, not enum, what should we be doing here?  It would be nice to be consistent.

"bool" is the natural type for these flags, so I suggest we stick with it.

        - Doug


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev