We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 28969f4 + 4a03e45 commit e362c30Copy full SHA for e362c30
tests/compile-fail/transmute_fat.rs
@@ -0,0 +1,13 @@
1
+#![feature(i128_type)]
2
+
3
+fn main() {
4
+ #[cfg(target_pointer_width="64")]
5
+ let bad = unsafe {
6
+ std::mem::transmute::<&[u8], u128>(&[1u8])
7
+ };
8
+ #[cfg(target_pointer_width="32")]
9
10
+ std::mem::transmute::<&[u8], u64>(&[1u8])
11
12
+ bad + 1; //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes
13
+}
tests/compile-fail/transmute_fat2.rs
+ std::mem::transmute::<u128, &[u8]>(42)
+ std::mem::transmute::<u64, &[u8]>(42)
+ bad[0]; //~ ERROR index out of bounds: the len is 0 but the index is 0
0 commit comments