Skip to content

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

@qsr

Description

@qsr

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

struct Foo {
  union {
    char d0[2];
    char d1[1];
    char d2[0];
  };
};

it ends up generating the following struct:

#[repr(C)]
pub struct Foo__bindgen_ty_1 {
    pub d0: __BindgenUnionField<[::std::os::raw::c_char; 2usize]>,
    pub d1: __BindgenUnionField<[::std::os::raw::c_char; 1usize]>,
    pub d2: __BindgenUnionField<[::std::os::raw::c_char; 0usize]>,
    pub __bindgen_padding_0: [u8; 18446744073709551615usize],
    pub bindgen_union_field: [u8; 2usize],
}

The __bindgen_padding_0 field is a little bit extreme.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions