6_8_31_switch_char_extremes.c (698B)
1 /* signed char selector at the extremes of i8 range. A jump-table 2 * lowering that pre-promotes the selector to a wider type without 3 * preserving signedness would silently miscompile case INT8_MIN. */ 4 static int pick(signed char c) { 5 switch (c) { 6 case -128: 7 return 1; 8 case -127: 9 return 2; 10 case 0: 11 return 3; 12 case 126: 13 return 4; 14 case 127: 15 return 5; 16 default: 17 return 9; 18 } 19 } 20 21 int test_main(void) { 22 int s = 0; 23 s += pick((signed char)-128); 24 s += pick((signed char)-127); 25 s += pick((signed char)0); 26 s += pick((signed char)127); 27 s += pick((signed char)42); /* miss -> 9 */ 28 return s - 15; /* 1+2+3+5+9 - 15 = 5 */ 29 }