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: Request of new __attribute__ for switch statements (eliminationof the bounds check)


Hi,

On Tue, 15 Oct 2002, Tim Hollebeek wrote:

> > If we wanted to stop people from shooting theirselves
> > in the feet, we wouldn't allow them to use C.  At
> > any rate, sometimes it's even possible to prove the
> > case targets are populated:
> >
> >   switch (a & 0x3) {
>
> then ask for the compiler to understand and DTRT with this syntax,
> instead of some funky attribute.

Although remember that we have two cases in this thread.  Things like
fully populated "switch (a & A_CONSTANT)" or "switch (a_char)", which
clearly should be optimized by the compiler itself without syntantic help.

And that "switch (an_enum)" thing, also "fully populated" in the sense
that all enumeration values are mentioned.  But due to the definition of
C/C++ this isn't fully populated, because an enum variable is equivalent
to a var of it's base int type, and can hold values without a name.  For
that we would need a syntactic mean to differentiate between standard
enums (named int constants) and real ones (a set).


Ciao,
Michael.


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