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 (elimination of the bounds check)


On Tue, Oct 15, 2002 at 06:38:10PM -0700, Kevin Lawton wrote:
> 
> --- Zack Weinberg <zack@codesourcery.com> wrote:
> 
> > Sure.  The question is how _soon_ you will be screwed to the point
> > that the program crashes.  Ideally this happens as soon after the
> > actual data corruption event as possible.
> 
[snip]
> 
> 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.

Sure, recognizing "switch ((expr) & (integral constant 2^n-1))" only
works for tables that are powers of two, but I suspect that would
already go quite a ways towards what many people need.

BTW, the "if you don't like the extension, don't use it" argument
doesn't wash.  Extensions have a non-trivial maintenance burden that
has to be supported by the gcc development team, and that's a far more
valuable resource than a few cycles in a few people's code.


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