This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Switch statement: extra out-of-bounds code emitted
- From: Chris Sears <cbsears_sf at yahoo dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 20 Dec 2001 14:17:21 -0800 (PST)
- Subject: Switch statement: extra out-of-bounds code emitted
Given a switch statement of the form:
unsigned char i;
switch ( i ) {
case 0: funct0(); break;
case 1: funct1(); break;
...
case 255: funct255(); break;
}
bounds checking the index variable is unnecessary.
I did a little research and this was suggested in 1989
and again in 1997, not exactly qualifying as an FAQ.
Can someone comment on this?
Chris Sears
__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com