When a type is `#[repr(simd)]`, `#[repr(align(N))]` annotations are ignored.
Open
Nobody has claimed this yet.
A-align
A-repr
A-SIMD
C-bug
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
See this example playground
#[repr(simd, align(32))]
struct Test([f32; 4]);
fn main() {
println!("{}", core::mem::align_of::<Test>());
}
I expected to see this happen: an alignment of at least 32 to be printed.
Instead, this happened: the alignment is only 16, the align of the underlying platform 128bit simd vector type.
Meta
Seen on playground nightly with version
(2024-09-14 9b72238eb813e9d06e9e)
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 running the linked nightly playground example and compare the alignment reported by core::mem::align_of::() with the #[repr(simd, align(32))] declaration. Trace the compiler's handling of repr(simd) and repr(align(N)) for this type. Done means the explicit alignment is honored and the example reports an alignment of at least 32.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100