Skip to content
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

bindgen with explicit padding generates an array of size 18446744073709551608 #3068

Open
qsr opened this issue Jan 6, 2025 · 0 comments
Open

Comments

@qsr
Copy link

qsr commented Jan 6, 2025

When running bindgen with the --explicit-padding option on the following file:

#include <stdint.h>
  
struct Foo {
  union {
    struct {
      uint64_t d1;
      uint64_t d2[1];
    };
    uint64_t d3;
    uint8_t d4[0];
  };
};

it ends up generating the following struct:

#[repr(C)]
pub struct Foo__bindgen_ty_1 {
    pub __bindgen_anon_1: __BindgenUnionField<Foo__bindgen_ty_1__bindgen_ty_1>,
    pub d3: __BindgenUnionField<u64>,
    pub d4: __BindgenUnionField<[u8; 0usize]>,
    pub __bindgen_padding_0: [u8; 18446744073709551608usize],
    pub bindgen_union_field: [u64; 2usize],
}

The __bindgen_padding_0 field is a little bit extreme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant