------- Additional Comments From bangerth at dealii dot org  2004-12-20 17:14 
-------
The question raised in several of the messages in that discussion 
is whether an enumeration of equality checks is converted into a 
range check if the tested values are consecutive. 
 
Here is the answer: 
-------------------- 
enum E  
{ 
      eins = 1, 
      zwei = 2, 
      drei = 3, 
      vier = 4, 
      fuenf= 5, 
      sechs= 6 
}; 
 
bool test_range (E e) 
{ 
  return e==drei || e==vier || e==fuenf; 
} 
------------------------ 
 
This is indeed compiled into a range check: 
_Z10test_range1E: 
        pushl   %ebp 
        movl    %esp, %ebp 
        movl    8(%ebp), %eax 
        popl    %ebp 
        subl    $3, %eax 
        cmpl    $2, %eax 
        setbe   %al 
        movzbl  %al, %eax 
        ret 
 
W. 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17617

Reply via email to