Is accessing Reference.field Undefined Behavior if the Reference's Tag has been popped?
โ Rust ๐ 2026-02-25 ๐ค surdeus ๐๏ธ 1I am investigating a specific case of Undefined Behavior (UB) under the Stacked Borrows memory model. I would like to confirm the physical mechanism of memory access when a referenceโs tag is no longer present in the borrow stack.
The Scenario
Suppose we have a structured type and a reference ref_a: &T (or &mut T) pointing to it. Due to a subsequent write operation via a raw pointer or a different unique reference, the Tag associated with ref_a is physically popped from the borrow stack of the underlying memory.
If the code subsequently attempts to access a nested field:
Rustlet x = ref_a.field_a.field_b;
Is it an UB? Miri does not report such an error:
6 posts - 3 participants
๐ท๏ธ Rust_feed