Skip to content

Instantly share code, notes, and snippets.

@Miezhiko
Created January 28, 2022 17:40
Show Gist options
  • Save Miezhiko/3594f02e178a80266baf6049c6cb2ba5 to your computer and use it in GitHub Desktop.
Save Miezhiko/3594f02e178a80266baf6049c6cb2ba5 to your computer and use it in GitHub Desktop.
fn f() {
let mut c: i64 = 1;
let d: i64 = 2;
let mut x: i64 = 3;
unsafe {
*(&mut x as *mut i64).sub(2) = 42;
}
println!("{c:?} {d:?} {x:?}");
unsafe {
*(&mut c as *mut i64).add(2) = 24;
}
println!("{c:?} {d:?} {x:?}");
}
fn main() {
f();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment