Skip to content

corrupt code is generated if the union contains an array. #1147

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
taro-yamada opened this issue Nov 10, 2017 · 1 comment
Closed

corrupt code is generated if the union contains an array. #1147

taro-yamada opened this issue Nov 10, 2017 · 1 comment

Comments

@taro-yamada
Copy link

Input C/C++ Header

//test.h
union TestUnion {
    int testArray[ 5 ] ;
} ;

Bindgen Invocation

bindgen test.h --no-derive-copy --no-derive-debug --no-layout-tests

Actual Results

/* automatically generated by rust-bindgen */

#[repr(C)]; 5usize ] , }

Expected Results

#[repr(C)]
pub union TestUnion {
    pub testArray : [ ::std::os::raw::c_int ; 5 ] ,
}

Environment

OS/distribution

ArchLinux

bindgen version

bindgen --version
bindgen 0.31.3

rustc version

rustc --version
rustc 1.23.0-nightly (d6b06c63a 2017-11-09)

clang version

clang --version
clang version 5.0.0 (tags/RELEASE_500/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

and also clang39 get same result.

Description

First of all, I'm sorry if my English is hard to understand.

If the union contains an array, bindgen generate strange code fragment like above.
I use "--no-derive-copy --no-derive-debug --no-layout-tests" flags here to reduce the code for explanation.
Even without them, I get the same corrupt code fragment.
And I also tried "--rust-target=nightly" flag but it does not take effect.

@emilio
Copy link
Contributor

emilio commented Nov 10, 2017

I think this is a rustfmt bug, and using --no-rustfmt-bindings or upgrading / using rustfmt-nightly should work, see #1045 and similar issues.

Thanks for the report!

@emilio emilio closed this as completed Nov 10, 2017
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

2 participants