I stumbled upon something a while ago and thought it might be interesting to share. What do you think the output of this code is?
fn () {
let : = {
let = 0u8;
& as *const _ as
};
let : = {
let = 0u8;
& as *const _ as
};
if != {
!("{a:?} != {b:?}");
}
if == {
!("{a:?} == {b:?}");
}
}
Drumroll please…
140736004887288 != 140736004887288
140736004887288 == 140736004887288
Surprise! Weird things happen in Rust when dealing with pointer-casted integers.
This is actually a bug in LLVM, with details that go over my head. From the looks of things, the issue isn’t even going away anytime soon. How fun!