Add tests for #113

resolves #113
This commit is contained in:
Oliver Schneider 2017-07-12 09:29:18 +02:00
parent 28969f47aa
commit 4a03e45169
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
}