rust-lang / rust-lang/rust-bindgen
Array members converted to pointers when using alias template
Open
Nobody has claimed this yet.
A-templates
I-failing-layout-test
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Input C/C++ Header
template<int N>
using vec = double[N];
struct Thing {
vec<3> position;
vec<4> orientation;
double diameter;
};
Bindgen Invocation
$ bindgen --no-layout-tests test.hpp
Actual Results
pub type vec = *mut f64;
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Thing {
pub position: vec,
pub orientation: vec,
pub diameter: f64,
}
impl Clone for Thing {
fn clone(&self) -> Self { *self }
}
Expected Results
pub struct Thing {
pub position: [f64; 3],
pub orientation: [f64; 4],
pub diameter: f64,
}
position and orientation are arrays of doubles. In the generated code, they are pointers.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the provided test.hpp input and the bindgen --no-layout-tests invocation. Compare the generated Thing fields with the expected [f64; 3] and [f64; 4] arrays; done means alias-template array members are no longer emitted as pointers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100