summaryrefslogtreecommitdiffstats
path: root/tests/codegen/issue-103285-ptr-addr-overflow-check.rs
blob: a3499babea21b07d40c2b232d14ca2b986b1ce95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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;
}