[jhc] foreign ptr bugs

Korcan Hussein korcan_h at hotmail.com
Thu Dec 30 01:45:43 CET 2010

Hi I mentioned this briefly in the past before, there is a bug when there are multiple foreign pointers in the same lexical scope obtained from (different) foreign binding functions. The pointer values end up having the same address this typically happens when GCC optimizations are enabled for which most of the time I can make code work correctly by adding -fdebug option to jhc.

I've attached some test code which prints out pointer values while trying to blit a loaded image to screen, you'll need to grab my modified version of the SDL Haskell bindings ( darcs get http://patch-tag.com/r/snk_kid/jhc-sdl there is a makefile in jhc folder just make, make install).

If you first try building the test code with the command:

jhc -p SDL test.hs -o test --optc='-lSDL'

and then see the result and output of the program running then try with adding "-fdebug" you should see the difference.

Another problem I've been having is erroneous C code generated with the same test code when I set the flag "-fno-global-optimize".

I'm using fedora, jhc-0.7.6

The image can be found here:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.hs
Type: application/octet-stream
Size: 606 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/jhc/attachments/20101230/cbc7d6d4/attachment.obj>

More information about the jhc mailing list