Closed
Description
This code compiles without warnings. I think that the improper_ctypes lint should catch both of the extern declarations.
#[allow(dead_code)]
#[repr(C)]
enum NotSoGood {
A,
B(i32),
}
extern "C" {
fn foo(a: [u8; 16]);
fn bar(a: NotSoGood);
}
#[no_mangle]
pub extern fn test() {
unsafe {
foo([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]);
bar(NotSoGood::B(0));
}
}
The array case (foo
) is particularly nasty. On brief, insufficiently careful inspection, it looks like it matches:
void foo(uint8_t a[16]);
But it actually doesn't match that and instead seems to try to pass the array in packed form in xmm0
on x86_64. This is extra nasty because I think I've caught rust-bindgen
generating bindings like this.