]> git.lizzy.rs Git - rust.git/blob - tests/codegen/issue-103285-ptr-addr-overflow-check.rs
Rollup merge of #106477 - Nathan-Fenner:nathanf/refined-error-span-trait-impl, r...
[rust.git] / tests / codegen / issue-103285-ptr-addr-overflow-check.rs
1 // compile-flags: -O -C debug-assertions=yes
2
3 #![crate_type = "lib"]
4 #![feature(strict_provenance)]
5
6 #[no_mangle]
7 pub fn test(src: *const u8, dst: *const u8) -> usize {
8     // CHECK-LABEL: @test(
9     // CHECK-NOT: panic
10     let src_usize = src.addr();
11     let dst_usize = dst.addr();
12     if src_usize > dst_usize {
13         return src_usize - dst_usize;
14     }
15     return 0;
16 }