diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:06:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:06:37 +0000 |
commit | 246f239d9f40f633160f0c18f87a20922d4e77bb (patch) | |
tree | 5a88572663584b3d4d28e5a20e10abab1be40884 /src/test/ui/sanitize/memory.rs | |
parent | Releasing progress-linux version 1.64.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-246f239d9f40f633160f0c18f87a20922d4e77bb.tar.xz rustc-246f239d9f40f633160f0c18f87a20922d4e77bb.zip |
Merging debian version 1.65.0+dfsg1-2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/sanitize/memory.rs')
-rw-r--r-- | src/test/ui/sanitize/memory.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/test/ui/sanitize/memory.rs b/src/test/ui/sanitize/memory.rs index b53f19a5b..14d4de65d 100644 --- a/src/test/ui/sanitize/memory.rs +++ b/src/test/ui/sanitize/memory.rs @@ -1,12 +1,15 @@ // needs-sanitizer-support // needs-sanitizer-memory // -// compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O +// revisions: unoptimized optimized +// +// [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O +// [unoptimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins // // run-fail // error-pattern: MemorySanitizer: use-of-uninitialized-value // error-pattern: Uninitialized value was created by an allocation -// error-pattern: in the stack frame of function 'main' +// error-pattern: in the stack frame // // This test case intentionally limits the usage of the std, // since it will be linked with an uninstrumented version of it. @@ -14,6 +17,7 @@ #![feature(core_intrinsics)] #![feature(start)] #![feature(bench_black_box)] +#![allow(invalid_value)] use std::hint::black_box; use std::mem::MaybeUninit; @@ -21,9 +25,9 @@ use std::mem::MaybeUninit; #[inline(never)] #[no_mangle] fn random() -> [isize; 32] { - let r = unsafe { MaybeUninit::uninit().assume_init() }; + let r = MaybeUninit::uninit(); // Avoid optimizing everything out. - black_box(r) + unsafe { std::intrinsics::volatile_load(r.as_ptr()) } } #[inline(never)] @@ -38,6 +42,6 @@ fn xor(a: &[isize]) -> isize { #[start] fn main(_: isize, _: *const *const u8) -> isize { - let r = random(); + let r = black_box(random as fn() -> [isize; 32])(); xor(&r) } |