Closed
Description
A fully populated switch with known value range (but no explicit default
clause) will still generate a conditional jump to the default destination:
void canthappen(void);
int g(int);
int f(int x) {
if (x >= 0 && x <= 3) {
switch (x) {
case 0: return g(2);
case 1: return g(3);
case 2: return g(4);
case 3: return g(5);
}
canthappen();
}
return -23;
}
results in a never-taken conditional branch to code that calls canthappen
.
llvm 18.0.0git (9f74e6e).