-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Returning an enum in 32-bit FFI is broken #10308
Comments
The problem which I have seen is that the function |
Looks like this is because all enums are represented by LLVM structs, and on i386 a struct is always returned by memory. (On amd64, return values use the same classification logic as arguments.) Enums (and structs) currently always turn into LLVM named structs so that recursion can be broken with forward declaration, but a C-like enum (no fields) can't have that problem. So that could be fixed... but the interface between |
On Tue, Nov 05, 2013 at 08:52:20PM -0800, Jed Davis wrote:
This is perhaps the right fix. We could also try to patch up the |
Work in progress: https://github.com/jld/rust/compare/enum-unstruct |
It makes the example at the top of the issue not crash, and examining the |
Somewhat related: #5347, the source of the change that uses LLVM-struct-ness to determine whether to treat the type as a struct for the purpose of the C ABI. (But also, as long as we're getting into history: I think the only reason that C-like enums had an extra struct wrapper in the first place is because it was easier to do it that way in the pre- |
Here's the output of a shell session on 32-bit linux which causes the failure.
cc @jld
The text was updated successfully, but these errors were encountered: