about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail-dep/libc/memcmp_zero.rs
blob: e28aa26270e49249b1fc9dab242f1bc06f19f1c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
//@compile-flags: -Zmiri-permissive-provenance

// C says that passing "invalid" pointers is UB for all string functions.
// It is unclear whether `(int*)42` is "invalid", but there is no actually
// a `char` living at that address, so arguably it cannot be a valid pointer.
// Hence this is UB.
fn main() {
    let ptr = 42 as *const u8;
    unsafe {
        libc::memcmp(ptr.cast(), ptr.cast(), 0); //~ERROR: dangling
    }
}