
Has anyone else come across this? I've only tried this with Word8 but I suspect this is a problem with all return types smaller than four bytes. I've entered this as GHC bug #448104. <http://sourceforge.net/tracker/index.php?func=detail&aid=448104&group_id=8 032&atid=108032> Here's the C code: 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 Kind of an unusual Word8 value! But note that the low byte of this value is zero. 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 -- Ashley Yakeley, Seattle WA
participants (1)
-
Ashley Yakeley