diff --git a/tests/run-pass/aligned_utf8_check.rs b/tests/run-pass/aligned_utf8_check.rs new file mode 100644 index 00000000000..0d2b2bf66a9 --- /dev/null +++ b/tests/run-pass/aligned_utf8_check.rs @@ -0,0 +1,13 @@ +fn main() { + const N: usize = 10; + + let x = vec![0x4141u16; N]; + + let mut y: Vec = unsafe { std::mem::transmute(x) }; + unsafe { y.set_len(2 * N) }; + + println!("{:?}", String::from_utf8_lossy(&y)); + + let mut x: Vec = unsafe { std::mem::transmute(y) }; + unsafe { x.set_len(N) }; +} diff --git a/tests/run-pass/aligned_utf8_check.stdout b/tests/run-pass/aligned_utf8_check.stdout new file mode 100644 index 00000000000..8d08312cac7 --- /dev/null +++ b/tests/run-pass/aligned_utf8_check.stdout @@ -0,0 +1 @@ +"AAAAAAAAAAAAAAAAAAAA"