Skip to content

bogus inlining of foreign import "foo.h &foo"

Foreign imports with include file annotations are not supposed to be inlined, because if they end up crossing a module boundary the include file might not be available when compiling the importing module.

This works by making the Id representing the foreign call NOINLINE, which is done in DsForeign.dsCImport. Unfortunately with the example below, the Id still gets inlined into another binding, and thereby escapes the module.

module Curses (screen_size) where

import Foreign

data WINDOW = WINDOW
type WINDOWptr = Ptr WINDOW

foreign import ccall unsafe "curses.h & stdscr" stdscrp :: Ptr WINDOWptr

screen_size :: IO ()
screen_size = do
  stdscr <- peek stdscrp
  return ()

Compile with GHC 6.8.2, -O.

Trac metadata
Trac field Value
Version 6.8.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information