Closed
Description
Given the following Rust code, compiled as a staticlib:
extern crate libc;
#[repr(C)]
pub struct LispObject(libc::c_int);
#[no_mangle]
pub extern "C" fn fcdr(list: LispObject) -> LispObject {
println!("fcdr: {:?}", list.0);
list
}
And the following C program to call it:
#include <stdio.h>
int fcdr(int);
int main() {
printf("call fcdr with 0\n");
fcdr(0);
return 0;
}
Running the compiled program on 32-bit linux isn't passing the int correctly:
$ ./example
call fcdr with 0
fcdr: -1077451660
Segmentation fault (core dumped)
64-bit linux works fine.
I have a full example repo here: https://github.com/Wilfred/rust_struct_test
I'm not sure if this is a bug with Rust itself, or in my code.
Metadata
Metadata
Assignees
Labels
No labels