Skip to content

GHC panic with UnliftedFFITypes+CApiFFI

The following code fails to compile with at least GHC 7.6, 7.8 and HEAD:

import GHC.Prim
import Foreign.C

type GmpLimb = CULong
type GmpSize = CLong

-- mp_limb_t mpn_add_1 (mp_limb_t *rp, const mp_limb_t *s1p, mp_size_t n, mp_limb_t s2limb)

foreign import capi unsafe "gmp.h mpn_add_1"
  c_mpn_add_1 :: MutableByteArray# s -> ByteArray# -> GmpSize -> GmpLimb -> IO GmpLimb

with the following compile error message:

ghc: panic! (the 'impossible' happened)
  (GHC version 7.9.20140704 for x86_64-unknown-linux):
	toCType MutableByteArray# s

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Otoh, replacing capi with ccall makes the code compile just fine

Trac metadata
Trac field Value
Version 7.6.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
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