make output bitwidth-independent

This commit is contained in:
Ralf Jung 2022-06-06 12:33:48 -04:00
parent b39e4c729a
commit 84edb76e26
2 changed files with 3 additions and 2 deletions

View File

@ -1,4 +1,5 @@
// error-pattern: type validation failed: encountered a pointer // error-pattern: type validation failed: encountered a pointer
// normalize-stderr-test: "\[u8; (08|16)\]" -> "$$ARRAY"
fn main() { fn main() {
#[cfg(target_pointer_width="64")] #[cfg(target_pointer_width="64")]
@ -7,7 +8,7 @@ fn main() {
}; };
#[cfg(target_pointer_width="32")] #[cfg(target_pointer_width="32")]
let bad = unsafe { let bad = unsafe {
std::mem::transmute::<&[u8], [u8; 8]>(&[1u8]) std::mem::transmute::<&[u8], [u8; 08]>(&[1u8])
}; };
let _val = bad[0] + bad[bad.len()-1]; let _val = bad[0] + bad[bad.len()-1];
} }

View File

@ -1,7 +1,7 @@
error: Undefined Behavior: type validation failed: encountered a pointer, but expected plain (non-pointer) bytes error: Undefined Behavior: type validation failed: encountered a pointer, but expected plain (non-pointer) bytes
--> $DIR/transmute_fat1.rs:LL:CC --> $DIR/transmute_fat1.rs:LL:CC
| |
LL | std::mem::transmute::<&[u8], [u8; 16]>(&[1u8]) LL | std::mem::transmute::<&[u8], $ARRAY>(&[1u8])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected plain (non-pointer) bytes | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected plain (non-pointer) bytes
| |
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior