rust-lang / rust-lang/reference
Guarantee that uninitialized bytes have no bit validity
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 607
- PR merge metrics
- PR metrics pending
Description
While this has been discussed before, it's not explicitly documented in the reference.
A few open questions:
- Does it make sense to speak about uninitialized bytes in general, or only about padding bytes? Does Rust currently have other forms of uninitialized bytes?
- Does it make sense to also define that uninitialized bytes cannot be "observed"? Currently, the closest that we have to this is statements on bit validity for various primitive types, which refer to uninitialized bytes, but do not define what they are (e.g., bools, numeric types, etc).
- I could see an argument that we don't need to talk about "observing" in the general sense; it is sufficient to define that it is UB to transmute an uninitialized byte to another type. In fact, it should technically be sufficient not to define that it is sound to transmute an uninitialized byte to a type; since there are no types for which this is sound, there exists no soundness proof for code which would attempt to do this regardless of "intermediate" type.
- Where would be best to document this?
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 reading the earlier unsafe-code-guidelines discussion and the Reference sections on bit validity for boolean and numeric types. Determine whether the Reference should define uninitialized bytes generally or only padding, and whether observation or transmutation needs explicit treatment; done means the open questions are resolved and the rule has a clear documentation location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100