1 use std::mem::transmute;
3 #[cfg(target_pointer_width = "32")]
5 #[cfg(target_pointer_width = "64")]
9 for &my_bool in &[true, false] {
10 let mask = -(my_bool as TwoPtrs); // false -> 0, true -> -1 aka !0
11 // This is branchless code to select one or the other pointer.
12 // However, it drops provenance when transmuting to TwoPtrs, so this is UB.
15 //~^ ERROR: constructing invalid value: encountered a dangling reference
16 !mask & transmute::<_, TwoPtrs>("false !")
17 | mask & transmute::<_, TwoPtrs>("true !"),