diff options
Diffstat (limited to '')
-rw-r--r-- | tests/ui/consts/const-eval/ub-ref-ptr.rs (renamed from src/test/ui/consts/const-eval/ub-ref-ptr.rs) | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/test/ui/consts/const-eval/ub-ref-ptr.rs b/tests/ui/consts/const-eval/ub-ref-ptr.rs index a1c812390..369e45194 100644 --- a/src/test/ui/consts/const-eval/ub-ref-ptr.rs +++ b/tests/ui/consts/const-eval/ub-ref-ptr.rs @@ -1,6 +1,9 @@ // ignore-tidy-linelength -// stderr-per-bitwidth +// Strip out raw byte dumps to make comparison platform-independent: +// normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" +// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" #![allow(invalid_value)] +#![feature(const_ptr_read)] use std::mem; @@ -57,4 +60,12 @@ const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; //~^ ERROR it is undefined behavior to use this value + +const UNALIGNED_READ: () = unsafe { + let x = &[0u8; 4]; + let ptr = x.as_ptr().cast::<u32>(); + ptr.read(); //~ inside `UNALIGNED_READ` +}; + + fn main() {} |