Closed
Description
I'm trying to craft a binding from rust into mruby (sebastianedwards/rust-mruby is obsolete). In debugging a segfault in a foreign function, I get conflicting answers as to the alignment of a rust struct.
#[repr(C)]
struct MRubyValue {
value: [u8, ..8],
tt: MRubyType,
}
Printing the size and align gives
println!("MRubyValue size {} align {}", std::mem::size_of::<MRubyValue>(),
std::mem::align_of::<MRubyValue>());
=>
MRubyValue size 12 align 8
I found some code on the internet which supposedly prints the same information, but the alignment is different.
let tyd =
unsafe {
(*std::intrinsics::get_tydesc::<T>())
};
println!("name: {} size: {} align: {}", tyd.name, tyd.size, tyd.align);
=>
name: MRubyValue size: 12 align: 4
Is this a rust problem or a misunderstanding of the output? Thanks.