diff options
Diffstat (limited to 'tests/codegen/issue-103285-ptr-addr-overflow-check.rs')
-rw-r--r-- | tests/codegen/issue-103285-ptr-addr-overflow-check.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/codegen/issue-103285-ptr-addr-overflow-check.rs b/tests/codegen/issue-103285-ptr-addr-overflow-check.rs new file mode 100644 index 000000000..a3499babe --- /dev/null +++ b/tests/codegen/issue-103285-ptr-addr-overflow-check.rs @@ -0,0 +1,16 @@ +// compile-flags: -O -C debug-assertions=yes + +#![crate_type = "lib"] +#![feature(strict_provenance)] + +#[no_mangle] +pub fn test(src: *const u8, dst: *const u8) -> usize { + // CHECK-LABEL: @test( + // CHECK-NOT: panic + let src_usize = src.addr(); + let dst_usize = dst.addr(); + if src_usize > dst_usize { + return src_usize - dst_usize; + } + return 0; +} |