Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardRustunsafe and the aliasing modelSingle-choice MCQ

What does this program do under the aliasing model, focusing on `&mut` reborrows passed through a function?

fn evil(a: &mut i32, b: &mut i32) -> i32 { *a = 10; *b = 20; *a // optimizer may assume a and b don't alias } fn main() { let mut x = 0; let r = &mut x; let p = r as *mut i32; let out = unsafe { evil(&mut *p, &mut *p) }; println!("{out}"); }