Skip to content

constructor for bitfield unit with 64 bit wide bitfields fails to build on 32 bit #1639

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

Closed
heycam opened this issue Oct 7, 2019 · 0 comments · Fixed by #1640
Closed

constructor for bitfield unit with 64 bit wide bitfields fails to build on 32 bit #1639

heycam opened this issue Oct 7, 2019 · 0 comments · Fixed by #1640

Comments

@heycam
Copy link
Contributor

heycam commented Oct 7, 2019

Input:

#include <stdint.h>

struct Test {
  uint64_t x : 56;
  uint64_t y : 8;
};

On 32 bit, rust-bindgen generates:

impl Test {
    ...
    #[inline]
    pub fn new_bitfield_1(
        x: u64,
        y: u64,
    ) -> __BindgenBitfieldUnit<[u8; 8usize], u64> {
        let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<
            [u8; 8usize],
            u64,
        > = Default::default();
        __bindgen_bitfield_unit.set(0usize, 56u8, {
            let x: [u32; 2usize] = unsafe { ::std::mem::transmute(x) };
            x as u64
        });
        __bindgen_bitfield_unit.set(56usize, 8u8, {
            let y: [u32; 2usize] = unsafe { ::std::mem::transmute(y) };
            y as u64
        });
        __bindgen_bitfield_unit
    }

This fails to compile with non-primitive cast: '[u32; 2usize]' as 'u64' errors.

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

Successfully merging a pull request may close this issue.

1 participant