Skip to content

extern const array is unexpectedly mut #1727

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
bobbobbio opened this issue Feb 12, 2020 · 3 comments · Fixed by #1730
Closed

extern const array is unexpectedly mut #1727

bobbobbio opened this issue Feb 12, 2020 · 3 comments · Fixed by #1730

Comments

@bobbobbio
Copy link

bobbobbio commented Feb 12, 2020

Input C/C++ Header

extern const int foo[1];

Bindgen Invocation

$ bindgen input.h

Actual Results

/* automatically generated by rust-bindgen */

extern "C" {
    pub static mut foo: [::std::os::raw::c_int; 1usize];
}

Expected Results

/* automatically generated by rust-bindgen */

extern "C" {
    pub static foo: [::std::os::raw::c_int; 1usize];
}

The const from the array seems to be lost. Arrays are a bit strange in C, but as best I can tell when you put const on an array it does in fact mean that values in the array are const, and as such the binding on the Rust side should not be mut.

@emilio
Copy link
Contributor

emilio commented Feb 17, 2020

Hmm... Yeah, this looks def. wrong. Var::is_const is returning false unexpectedly. I don't think this should be very hard to track down.

@emilio
Copy link
Contributor

emilio commented Feb 17, 2020

So the clang type for this test-case is const int [1], kind: ConstantArray. But clang_isConstQualifiedType returns false for that...

@bobbobbio
Copy link
Author

I knows its a little late, but thank you for fixing this!

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

Successfully merging a pull request may close this issue.

2 participants