Skip to content

Commit bf8b2aa

Browse files
committed
add test for better ptr handling in enum niches
1 parent a1233a7 commit bf8b2aa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// A niche-optimized enum where the discriminant is a pointer value -- relies on ptr-to-int casts in
2+
// the niche handling code.
3+
// compile-flags: -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
4+
5+
fn main() {
6+
let x = 42;
7+
let val: Option<&i32> = unsafe { std::mem::transmute((&x as *const i32).wrapping_offset(2)) };
8+
assert!(val.is_some());
9+
}

0 commit comments

Comments
 (0)