[ ghc-Bugs-830247 ] When compiled with -O2, we get extra warnings

SourceForge.net noreply at sourceforge.net
Sat Oct 25 17:34:59 EDT 2003


Bugs item #830247, was opened at 2003-10-25 23:10
Message generated for change (Comment added) made by wthaller
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=830247&group_id=8032

Category: Compiler (FFI)
Group: 6.0.1
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: When compiled with -O2, we get extra warnings

Initial Comment:
This is happending on a WinXP installation:
-----------------------------------------------
[arf]~/tst>cat Main.hs
module Main where

import CString

foreign import ccall "readline"  gnuRL :: CString -> IO 
CString

main = main
[arf]~/tst>ghc --version
The Glorious Glasgow Haskell Compilation System, 
version 6.0.1
[arf]~/tst>ghc -c -ffi Main.hs
[arf]~/tst>rm Main.o Main.hi
[arf]~/tst>ghc -O2 -c -ffi Main.hs
c:/DOCUME~1/lerkok/LOCALS~1/Temp/ghc2484.hc: In 
function `s1cV_entry':
c:/DOCUME~1/lerkok/LOCALS~1/Temp/ghc2484.hc:52: 
warning: implicit declaration of function `readline'
c:/DOCUME~1/lerkok/LOCALS~1/Temp/ghc2484.hc:52: 
warning: assignment makes pointer from integer without 
a cast
--------------------------------------------------

For some reason, compiling with -O2 produces these 
warnings that don't show up otherwise.


----------------------------------------------------------------------

>Comment By: Wolfgang Thaller (wthaller)
Date: 2003-10-25 23:34

Message:
Logged In: YES 
user_id=566359

You need to specify a header file in the foreign import declaration, 
like this:
foreign import ccall "readline/readline.h readline" gnuRL :: CString 
-> IO CString
or on the command line, using the -# include option, or in an 
OPTIONS pragma.

The reason why these warnings are only reported with -O is that 
GHC uses it's own native code generator most of the time, which 
doesn't use the headers, but uses GCC when optimizing, which 
does use them.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=830247&group_id=8032


More information about the Glasgow-haskell-bugs mailing list