-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-langRelevant to the language teamRelevant to the language team
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.
Metadata
Metadata
Assignees
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-langRelevant to the language teamRelevant to the language team