Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

The reference does not allow in-bounds reads of "partially dangling" pointers, whereas Miri does.

Open
#2,356 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
documentation

Research direction

Start with the Rust Reference sections on dangling pointers, pointed-to bytes, allocations, and undefined behavior, then reproduce the supplied example in Miri. Compare the Reference wording with Miri's behavior and determine the documentation change needed to resolve whether partially dangling pointers may be read; done means the semantics and example are described consistently.

Written by the indexing model from the issue text.

Description

Miri accepts this code, which prints 42:

#[repr(C)]
struct X {
    a: usize,
}

#[repr(C)]
struct Y {
    a: usize,
    b: usize,
}

fn main() {
    unsafe {
        let x = X { a: 42 };
        let py = &raw const x as *const Y;
        let Y { a, .. } = *py;
        println!("{a}");
    }
}

On the other hand, the reference defines a dangling pointer as follows:

A reference/pointer is “dangling” if not all of the bytes it points to are part of the same live allocation (so in particular they all have to be part of some allocation).

And mentions as undefined behavior:

Accessing (loading from or storing to) a place that is dangling

Clearly, py is dangling by this definition, and clearly, the line let Y { a, .. } = *py; loads from py. So according to the reference, this should be UB. The reference does not have any notion of a "partially dangling" pointer that it's okay to read part of. Who is right: the reference or miri?

Dominant language
Rust
Stars
1.6k
Forks
609
Avg merge
1d 4h
Merged PRs (30d)
7

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-lang/reference

All issues in rust-lang/reference

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.