-
Notifications
You must be signed in to change notification settings - Fork 721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to generate Default
impl for arrays larger than 32 entries
#2803
Comments
Which rust version are you using? We have code to deal with this, see a380678 |
Ah, so I couldn't repro this, but that's because for some reason
Is the command I used to reproduce. It seems the |
And somehow that only happens when targeting windows |
I think that limitation in rustc is mostly historical? rust-lang/rust#124163 removes it. |
…r than 32 elements. Much like rust-lang#74060 did for every other trait. This avoids tools like rust-bindgen having to painfully work around this limitations, sometimes incorrectly like in rust-lang/rust-bindgen#2803
I'm able to repro on latest stable(
I am using x64 windows w/ msvc toolchain, so my native target is I've also tried enabling clang's msvc compat, and it doesn't alter behavior here:
|
@emilio looks like your proposed patch to rust was rejected. Can this continue to be handled by bindgen? |
I think this issue is a bit deeper than just a missing // hello.c
typedef struct bar {
int *a[17];
} bar;
typedef struct foo {
bar;
int b;
} foo; and ran /* automatically generated by rust-bindgen 0.69.4 */
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct bar {
pub a: [*mut ::std::os::raw::c_int; 17usize],
}
impl Default for bar {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
#[repr(C)]
#[repr(align(8))]
#[derive(Debug, Default, Copy, Clone)]
pub struct foo {
pub __bindgen_padding_0: [u32; 34usize],
pub b: ::std::os::raw::c_int,
} implementing |
bruh |
Some platform definitions make bindgen unhappy (#1882, rust-lang/rust-bindgen#2803 when compiling for x86_64-windows-msvc, `serialization error at builtin definitions: Cannot serialize type kind Opaque` when compiling for x86_64-windows-gnu on my machine), and `allowlist_file` could ensure that it does not happen.
Input C/C++ Header
Bindgen Invocation
Actual Results
and/or
Expected Results
I expected it to generate a default implementation successfully. This seems to be another regression of #1718/#1719 and #2082, where it fails to generate a valid
Default
when the array has more than the 32 entries (where rust itself generates aDefault
for <=32 entries).The text was updated successfully, but these errors were encountered: