Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardRustraw pointers and UnsafeCellSingle-choice MCQ

Why is `&mut` over a field of a struct behind a shared reference still potentially UB under Stacked Borrows even when wrapped logic 'looks' like interior mutability?

use std::cell::Cell; struct S { c: Cell<u32>, plain: u32 } let s = S { c: Cell::new(0), plain: 5 }; let r: &S = &s; let p = &r.plain as *const u32 as *mut u32; unsafe { *p = 9; } // ?