rust-lang / rust-lang/rust-bindgen
__attribute__((aligned(2), packed)) generates both repr(packed) and repr(aligned)
Open
Nobody has claimed this yet.
A-rustc
bug
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Input C/C++ Header
part of MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/hfs/hfs_format.h
#define int8_t char
struct FndrOpaqueInfo {
int8_t opaque[16];
} __attribute__((aligned(2), packed));
Bindgen Invocation
$ bindgen has_format.h
Actual Results
#[repr(C, packed(2))]
#[repr(align(2))]
#[derive(Debug, Copy, Clone)]
pub struct FndrOpaqueInfo {
pub opaque: [::std::os::raw::c_char; 16usize],
}
Expected Results
#[repr(C, packed(2))]
#[derive(Debug, Copy, Clone)]
pub struct FndrOpaqueInfo {
pub opaque: [::std::os::raw::c_char; 16usize],
}
The actual result is illegal in Rust.
#[repr(C, packed(2))]
#[repr(align(2))]
any of below will be accepted
#[repr(C, packed(2))]
#[repr(C)]
#[repr(align(2))]
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
Reproduce the issue using the shown hfs_format.h input and the bindgen has_format.h invocation. Compare the generated FndrOpaqueInfo attributes with the expected output; done means the binding no longer emits both repr(packed(2)) and repr(align(2)).
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100