
For testing purposes, I created the following Cmm program:
myswitch (bits32 n) {
switch [0 .. 4] n {
case 0, 1: { foreign "C" A(); }
case 2: { foreign "C" B(); }
case 4: { foreign "C" C(); }
default: { foreign "C" D(); }
}
return (666);
}
In the original C-- specification, it's pretty clear that when, say,
the call to foreign function `A` terminates, the switch statement is
supposed to finish and function `myswitch` is supposed to return 666.
What actually happens in GHC is that this source code is parsed into a
control-flow graph in which execution loops forever, repeating the
call. The relevant fragment of the prettyprinted CFG looks like this:
{offset
ca: // global
_c1::I32 = %MO_XX_Conv_W64_W32(R1);
//tick src