about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail-dep/libc/memcpy_zero.rs
blob: b37ed7df74ffa21cab60256b74397fc6556ed8b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
//@compile-flags: -Zmiri-permissive-provenance
// C's memcpy is 0 bytes is UB for some pointers that are allowed in Rust's `copy_nonoverlapping`.

fn main() {
    let from = 42 as *const u8;
    let to = 23 as *mut u8;
    unsafe {
        to.copy_from(from, 0); // this is fine
        libc::memcpy(to.cast(), from.cast(), 0); //~ERROR: dangling
    }
}