-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bool corruption across extern and FFI calls #36
Comments
I'm starting to think this is a bug in GHC, since regular C/C++ code uses |
Just spoke to Igloo... the |
I think it is never correct to use a Haskell type in a C binding. It should always be CInt (~ int), CChar (~ char), Word8 (~ uint8) and so on. Unfortunately a lot of CInt's were replaced by Bool in the FFI recently. I would prefer to have a CBool type. |
If you see any such corruptions can you send a patch? I agree it's the wrong thing and LLVM definitely treats its Bool (i1) type as a single bit. |
The CInts that were replaced by Bool were not in the calls to functions generated by LLVM, but in the LLVM functions themselves. One can easily find them using grep: |
Patches would be appreciated 👍 |
On Sat, 18 May 2013, Nathan Howell wrote:
Just a note on the maintenance procedure: Someone has changed CInt to Bool My remaining question is whether we should simply roll-back the patch or |
We're aware of the problem. If you don't have the time or desire to roll the patch back I'll try to get it done soon. |
On Sat, 18 May 2013, Nathan Howell wrote:
What is your opinion about the question "rollback to CInt" vs. "keep Bool, |
|
The erroneous uses of Bool instead of CInt in the FFI have been corrected in 2f86bd. As this has little to do with the original issue, this issue remains open. |
The LLVM bindings map the
Bool
type to ani1
. This works fine (though perhaps a bit slow) within LLVM generated code but does not work withexternFunction
mappings orforeign imports
in Haskell. In this exampleret (valueOf False)
is compiled toxor $al
, leaving trash in upper bits of$rax
. I propose mappingBool
to ai32
ori64
instead of ani1
.The text was updated successfully, but these errors were encountered: