<div dir="ltr">I've been looking into the generated C code. The problem seems to be caused by an erroneous optimization that causes the tag for the variant type T3 to be dropped altogether. This would be OK, since the other two constructors are immediate (i.e. aren't boxed) and therefore, at runtime, you can just check if the constructor is a pointer and if it is, then it must be T3C3, and if it's not, check the immediate tag. However, while the representation of the constructors is optimized, the code that checks for tags is not, and expects T3C3 to be tagged. <div><br></div><div>If you added parameters to any other T3 constructors the optimization wouldn't be triggered and there would be no bug.<div><br></div><div>I'm a bit hesitant to look further into this, as I'm not involved in the development of JHC (I just happen to have some understanding of the C backend). However, since my current project depends heavily on JHC, if nobody else steps up I might try to fix it myself.</div><div><br></div><div>Cheers!</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 8, 2015 at 6:01 PM, Herbert Valerio Riedel <span dir="ltr"><<a href="mailto:hvriedel@gmail.com" target="_blank">hvriedel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
When compiling and running the following trivial Haskell program below w/ jhc<br>
0.8.2, it aborts right away with a "case fell off" error (see output<br>
below)<br>
<br>
As this seems to be a rather visible bug, is this actually a known issue?<br>
<br>
--8<---------------cut here---------------start------------->8---<br>
data T2 = T2C1 | T2C2 String<br>
         deriving (Show,Eq)<br>
<br>
data T3 = T3C1 | T3C2 | T3C3 String<br>
         deriving (Show,Eq)<br>
<br>
main :: IO ()<br>
main = do<br>
    print (T2C2 "works fine")<br>
    print (T3C3 "case falls off")<br>
--8<---------------cut here---------------end--------------->8---<br>
<br>
<br>
...output when run:<br>
<br>
--8<---------------cut here---------------start------------->8---<br>
T2C2 "works fine"<br>
<br>
/tmp/jhc_8nHiAa/rts/rts_support.c:887: case fell off<br>
Aborted<br>
--8<---------------cut here---------------end--------------->8---<br>
<br>
<br>
Cheers,<br>
  hvr<br>
_______________________________________________<br>
jhc mailing list<br>
<a href="mailto:jhc@haskell.org">jhc@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/jhc" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/jhc</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr">Now I do not know whether I was then a lambda expression emulating a Turing machine, or whether I am a Turing machine emulating a lambda expression.<br></div></div></div></div>
</div>