Skip to content

4.08.2: foreign export dynamic broken for CTypes

Here the first nasty bug in the 4.08.2 release :-/

Given the module

import Addr
import CTypes

foreign export ccall dynamic 
  mkHandler :: (CInt -> IO ()) -> IO Addr

main = print 42

4.08.2 when invoked with

  ghc -fglasgow-exts -o test test.hs

dies with

In file included from test_stub.c:1,
test_stub.h:2:63: warning: no newline at end of file
test_stub.c:11:1: warning: no newline at end of file
In file included from test_stub.c:2,
test_stub.h:2: parse error before `StgCInt'
test_stub.c:4: parse error before `StgCInt'
test_stub.c:8: `a0' undeclared (first use in this function)
test_stub.c:8: (Each undeclared identifier is reported only once
test_stub.c:8: for each function it appears in.)
test_stub.c:8: warning: implicit declaration of function `rts_mkCInt'
test_stub.c:8: `a1' undeclared (first use in this function)
test_stub.c:8: warning: passing arg 2 of `rts_apply' makes pointer from integer without a cast

The reason is that it generates the non-existent type `StgCInt' in the _stub file.  4.11 generates `HsInt32' instead (or whatever size it has on the current architecture, I hope), which works fine.
Trac metadata
Trac field Value
Version None
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution ResolvedFixed
Component Compiler (FFI)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information