#5664: Missing checks for FFI declaration types
---------------------------------+------------------------------------------
    Reporter:  simonmar          |       Owner:  pcapriotti                 
        Type:  bug               |      Status:  new                        
    Priority:  normal            |   Milestone:  7.6.1                      
   Component:  Compiler (FFI)    |     Version:  7.2.1                      
    Keywords:                    |          Os:  Unknown/Multiple           
Architecture:  Unknown/Multiple  |     Failure:  GHC accepts invalid program
  Difficulty:  Unknown           |    Testcase:                             
   Blockedby:                    |    Blocking:                             
     Related:                    |  
---------------------------------+------------------------------------------

Comment(by pcapriotti):

 Here is the relevant portion of the FFI specification in the Haskell 2010
 report:

 {{{

 Dynamic import.
 The type of a dynamic stub has to be of the form (FunPtr ft) -> ft, where
 ft may be any foreign type.
 As an example, consider

 foreign import ccall "dynamic"
   mkFun :: FunPtr (CInt -> IO ()) -> (CInt -> IO ())
 The stub factory mkFun converts any pointer to a C function that gets an
 integer value as its only argument and does not have a return value into a
 corresponding Haskell function.

 Dynamic wrapper.
 The type of a wrapper stub has to be of the form ft -> IO (FunPtr ft),
 where ft may be any foreign type.
 As an example, consider

 foreign import ccall "wrapper"
   mkCallback :: IO () -> IO (FunPtr (IO ()))
 The stub factory mkCallback turns any Haskell computation of type IO ()
 into a C function pointer that can be passed to C routines, which can call
 back into the Haskell context by invoking the referenced function.

 }}}

 We are currently checking whether the signature of a dynamic (resp.
 wrapper) import has a `FunPtr` argument (resp. result), but not if the
 wrapped function type is correct.

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

_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to