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: Help with bit-field semantics in C and C++


Michael Matz <matz@suse.de> writes:

[...]

| If the performance degradation in this case is really noticable might be
| under discussion but I think the C++ standard should allow a performant
| solution by default, without requiring hacks like:
| 
| enum { a, b, other_fields ..., BIG_ENOUGH_TO_WIDEN_THE_ENUM=0xffffffff }

Use reinterepret_cast if your intent is to treat an enumeration
variable as an integer, instead of a dictint type with its own range.

| > I don't think so.  The explicit cast also suggests that the conversion
| > may not be a nop.
| 
| IMHO it suggests type safety.

And what is type safety about, if not to make sure that values are
stored and accessed in ways that preserve type invariants?

| I'm against the notion that any syntactic
| structure already implicitely suggests a certain behaviour, in this case
| non-nopiness ;)  It is the case for some such structures, but this should
| not be used as excuse for allowing also other constructs to be non-nops,

But it is not an no-op.

-- Gaby


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