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


Joe Buck wrote:

[ issues connected with limited range of C++ enums ]
On Tue, Aug 24, 2004 at 10:32:39AM -0600, Roger Sayle wrote:


I'm happy with the explanations so far. The next question is, if
the middle-end is supposed to treat loads, stores and comparisons
of these types identically to the underlying integer type for the
enumeration, is there a benefit for setting TYPE_PRECISION lower
than GET_MODE_BITSIZE for C++'s enumerated types?



I think that the middle end should, at least by default, try to generate
the best code possible for conformant programs that use C++ enums. In
most cases, that probably means treating them as belonging to the
underlying integer type; the exception would be where the limited range
allows for, say, more efficient switch statements, or to determine that
some code is unreachable.


I agree.

PR 10796 was the motivation for the current implementation. A secondary motivation was, as Joe says, to allow the middle-end to generate better code for switch/if/etc. situations where it could prove that, because of the limited range, certain values were impossible.

--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com


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