Skip to content

Wrong layout #1041

Closed
Closed
@e00E

Description

@e00E

Input C/C++ Header

#pragma pack(push)
#pragma pack(1)
struct S5 {
   signed f0 : 11;
   unsigned f1 : 12;
   unsigned f2 : 23;
};
#pragma pack(pop)

Bindgen Invocation

$ bindgen failing.h -o failing.rs

Actual Results

While running bindgen we get:

ERROR:bindgen::codegen::struct_layout: Calculated wrong layout for S5, too more 2 bytes

but the output is created nonetheless:

[repr(C)]
#[derive(Debug, Copy)]
pub struct S5 {
    pub _bitfield_1: [u32; 2usize],
    pub __bindgen_align: [u8; 0usize],
}

Then when running the tests:

---- bindgen_test_layout_S5 stdout ----
        thread 'bindgen_test_layout_S5' panicked at 'assertion failed: `(left == right)`
  left: `8`,
 right: `6`: Size of: S5', failing.rs:11:4

Expected Results

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