rust-bindgen
rust-bindgen copied to clipboard
Disallow passing `_Complex` by value
As seen in https://github.com/rust-lang/rfcs/issues/793 and https://github.com/rust-lang/libc/issues/355, C’s _Complex has a different ABI (but not layout) to what Bindgen currently generates, which is:
#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
#[repr(C)]
pub struct __BindgenComplex<T> {
pub re: T,
pub im: T,
}
As a soundness fix, I suggest erroring when the user attempts to use _Complex by value. Maybe this could be done with a flag to disable it if the user really wants the potentially-unsound behaviour?