about summary refs log tree commit diff
path: root/tests/ui/codegen/equal-pointers-unequal/strict-provenance/inline1.rs
blob: 0b5b2df9f0e5252be26595b7a5e31bddc7473282 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//@ known-bug: #107975
//@ compile-flags: -Copt-level=2
//@ run-pass
//@ ignore-backends: gcc

// Based on https://github.com/rust-lang/rust/issues/107975#issuecomment-1432161340

use std::ptr;

#[inline(never)]
fn cmp(a: usize, b: usize) -> bool {
    a == b
}

#[inline(always)]
fn cmp_in(a: usize, b: usize) -> bool {
    a == b
}

fn main() {
    let a: usize = {
        let v = 0;
        ptr::from_ref(&v).addr()
    };
    let b: usize = {
        let v = 0;
        ptr::from_ref(&v).addr()
    };
    assert_eq!(format!("{}", a == b), "false");
    assert_eq!(format!("{}", cmp_in(a, b)), "false");
    assert_eq!(format!("{}", cmp(a, b)), "true");
    assert_eq!(a.to_string(), b.to_string());
}