Re: Removing bound checks from a switch statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/17/10 10:55, Henrik Mannerström wrote:
Hello,

Below is a short program that illustrates my problem. The variable R is of type enum reactions so the compiler should know that it does not need to check it's value in the switch statement on line 10. The assembler output shows that a check is nevertheless inserted. %ebx contains the value or R and .L9 the address of the jump table. Compiled with g++ -S -g -dA -O2 swloop.cc on a X86_64 machine.

Should not the type system ensure that R is within bounds?
No. The standard allows defining values that are not part of the enumeration.

Jeff

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux