Bugs item #448104, was opened at 2001-08-05 00:44
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=108032&aid=448104&group_id=8032
Category: Compiler (FFI)
Group: 5.00
Status: Open
Resolution: None
Priority: 5
Submitted By: Ashley Yakeley (ashley-y)
>Assigned to: Julian Seward (sewardj)
Summary: imported return type not masked
Initial Comment:
This might be difficult to reproduce. Try this:
Haskell looks like this:
foreign import foo :: IO Word8
do {
f <- foo;
putStrLn (show f);
}
C looks like this:
HsWord8 foo ()
{
HsWord8 f;
... f should be zero
return f;
}
On running, I might get something like this:
1074803456
...which is clearly not a Word8, although the low byte is zero.
----------------------------------------------------------------------
>Comment By: Ashley Yakeley (ashley-y)
Date: 2001-10-07 21:51
Message:
Logged In: YES
user_id=19233
I take it this is not fixed in 5.02...
----------------------------------------------------------------------
Comment By: Ashley Yakeley (ashley-y)
Date: 2001-08-05 17:25
Message:
Logged In: YES
user_id=19233
My setup:
$ ghc -v
Glasgow Haskell Compiler, Version 5.00, for Haskell 98, compiled by GHC
version 5.00
Using package config file: /usr/lib/ghc-5.00/package.conf
Hsc static flags: -static -fignore-interface-pragmas -fomit-interface-pragmas
-fdo-lambda-eta-expansion -flet-no-escape
$ uname -a
Linux server 2.2.19pre17 #1 Tue Mar 13 22:37:59 EST 2001 i686 unknown
----------------------------------------------------------------------
Comment By: Ashley Yakeley (ashley-y)
Date: 2001-08-05 17:18
Message:
Logged In: YES
user_id=19233
OK, here's an example:
extern "C"
{
unsigned char foo();
}
inline void use(const char* s)
{
}
unsigned char foo()
{
const char* s = "";
use(s);
return 0;
}
...and the Haskell looks something like this:
foreign import foo :: IO Word8
do {
w8 <- foo;
putStrLn (show (w8 :: Word8));
}
...and the result is this:
1074803712
Note that the low byte of this value is (correctly) zero. Unfortunately the high three
bytes are not.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=108032&aid=448104&group_id=8032