Trying to figure out if this is a UB


#1

I have this:

fn main() {
    let mut v = vec![0u8,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; //16 bytes

    unsafe{
        let p : *mut i32= std::mem::transmute(v[0..15].as_mut_ptr()); //take a 4 bytes pointer

        *p.offset(0) = 1i32;
        *p.offset(1) = 2i32;
        *p.offset(2) = 3i32;
        *p.offset(3) = 4i32;
        //by now i expect only 4 values to be in v
        
        println!("{}", *p.offset(0));
        println!("{}", *p.offset(1));
        println!("{}", *p.offset(2));
        println!("{}", *p.offset(3));
        
        //undefined behavior henceforth?
        println!("{}", *p.offset(4));
        println!("{}", *p.offset(5));
        println!("{}", *p.offset(6));
        println!("{}", *p.offset(7));
        println!("{}", *p.offset(8));
        println!("{}", *p.offset(9));
        println!("{}", *p.offset(10));
        println!("{}", *p.offset(11));
        println!("{}", *p.offset(12));
        println!("{}", *p.offset(13));
        println!("{}", *p.offset(14));
        println!("{}", *p.offset(15));
        println!("{}", *p.offset(16));

    }    
}

I suppose it is a UB.
You can play with it here: https://is.gd/Yj6uvW