[GHC] #2152: bogus inlining of foreign import "foo.h &foo"

GHC trac at galois.com
Thu Mar 13 18:16:52 EDT 2008


#2152: bogus inlining of foreign import "foo.h &foo"
-------------------------+--------------------------------------------------
    Reporter:  simonmar  |       Owner:         
        Type:  bug       |      Status:  new    
    Priority:  normal    |   Milestone:  6.8.3  
   Component:  Compiler  |     Version:  6.8.2  
    Severity:  normal    |    Keywords:         
  Difficulty:  Unknown   |    Testcase:         
Architecture:  Unknown   |          Os:  Unknown
-------------------------+--------------------------------------------------
 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.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2152>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list