diff options
Diffstat (limited to 'tests/ui/ptr_ops/issue-80309.rs')
-rw-r--r-- | tests/ui/ptr_ops/issue-80309.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/ui/ptr_ops/issue-80309.rs b/tests/ui/ptr_ops/issue-80309.rs new file mode 100644 index 000000000..c13ce3c9c --- /dev/null +++ b/tests/ui/ptr_ops/issue-80309.rs @@ -0,0 +1,13 @@ +// run-pass +// compile-flags: -O + +// Regression test for issue #80309 + +pub unsafe fn foo(x: *const i8) -> i8 { + *x.wrapping_sub(x as _).wrapping_add(x as _) +} + +fn main() { + let x = 42; + println!("{}", unsafe { foo(&x) }); +} |