Closed
Description
As you know, GNU C and C++ supports Arrays of Length Zero in different syntax. For int A[]
, LLVM has a IncompleteArrayType where the size is unspecified.
For example, we have two array in a class
class C {
int a;
// More than rust limits (32)
char big_array[33];
char zero_length_array[0];
char incomplete_array[];
};
The incomplete array will be generated as a pointer, which cause the layout test failed
#[repr(C)]
pub struct C {
pub a: ::std::os::raw::c_int,
pub big_array: [::std::os::raw::c_char; 33usize],
pub zero_length_array: [::std::os::raw::c_char; 0usize],
pub incomplete_array: *mut ::std::os::raw::c_char,
}
#[test]
fn bindgen_test_layout_C() {
assert_eq!(::std::mem::size_of::<C>() , 40usize);
assert_eq!(::std::mem::align_of::<C>() , 4usize);
}
failures:
---- bindgen_test_layout_C stdout ----
thread 'bindgen_test_layout_C' panicked at 'assertion failed:(left == right)
(left:48
, right:40
)', tests/class.rs:40
We should treat the incomplete array as a zero length array, or add a helper class like __BindgenUnionField<T>
did.
Metadata
Metadata
Assignees
Labels
No labels