Warn that `repr(packed)` and `repr(align)` do not guarantee field order, and as a result do not guarantee size
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- rust
- Domain
- documentation
Research direction
Start with the linked type layout documentation and read the sections on repr(packed) and repr(align). Update the documentation to explain field-order effects on size, the repr(packed(1)) and repr(packed) exception, and when repr(C) is needed; done means all three cases are stated clearly.
Written by the indexing model from the issue text.
Description
While this is already implied by the type layout docs, it's easy to miss since the type layout docs describe reprs as guaranteeing things about the layout, and the special case of repr(packed(1)) does guarantee size.
In particular, call out the following:
- A
repr(packed(N))struct's size may change depending on field order- As a special case, a
repr(packed(1))orrepr(packed)struct's size does not depend on field order
- As a special case, a
- A
repr(align(N))struct's size may change depending on field order - In each of these cases, suggest using
repr(C)to guarantee field order if guaranteed size is important
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 607
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 12
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.
More from rust-lang/reference
-
A-const-eval A-undefined-behavior
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
A-resolve
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
A-coercions
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
All issues in rust-lang/reference
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100