Merge pull request #242 from solson/various

Add tests for #113
This commit is contained in:
Oliver Schneider 2017-07-12 10:40:02 +02:00 committed by GitHub
commit e362c30ef8
2 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,13 @@
#![feature(i128_type)]
fn main() {
#[cfg(target_pointer_width="64")]
let bad = unsafe {
std::mem::transmute::<&[u8], u128>(&[1u8])
};
#[cfg(target_pointer_width="32")]
let bad = unsafe {
std::mem::transmute::<&[u8], u64>(&[1u8])
};
bad + 1; //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes
}

View file

@ -0,0 +1,13 @@
#![feature(i128_type)]
fn main() {
#[cfg(target_pointer_width="64")]
let bad = unsafe {
std::mem::transmute::<u128, &[u8]>(42)
};
#[cfg(target_pointer_width="32")]
let bad = unsafe {
std::mem::transmute::<u64, &[u8]>(42)
};
bad[0]; //~ ERROR index out of bounds: the len is 0 but the index is 0
}