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++


On Sat, 28 Aug 2004 15:56:43 +0200 (CEST), Michael Matz <matz@suse.de> said:

> In this case I think the C++ standard should be changed in a way to
> not require a masking operation for each and every assignment from
> an integer of which the range is unknown.  Yes this masking happens
> only for such casts, and not for every operation if the operands are
> enums already, but it still will hurt performance in the real world.

It seems to me that (different) people have expressed incompatible
desires here:

1) integer => enum should be as fast as possible.

2) switch(enum) should be able to safely handle all possible values
   that can arise via integer => enum conversion, falling through or
   taking the default: branch on values that aren't explicitly
   mentioned in case labels.

3) switch (enum) should be as fast as possible.

Personally, desire #2 is the most important of these to me, which
means that we have to chose between desire #1 and desire #3.  I would
rather have my switch statements be efficient than my type conversion
operations - I can usually move the type conversion operations to the
boundaries of my code easily enough, whereas it's not always so easy
to move the switch statements to the boundaries of my code.

Of course, that's all off the top of my head - I haven't done any
measurements here.

David Carlton
david.carlton@sun.com


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