1 // needs-sanitizer-support
2 // needs-sanitizer-memory
4 // revisions: unoptimized optimized
6 // [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O
7 // [unoptimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins
10 // error-pattern: MemorySanitizer: use-of-uninitialized-value
11 // error-pattern: Uninitialized value was created by an allocation
12 // error-pattern: in the stack frame
14 // This test case intentionally limits the usage of the std,
15 // since it will be linked with an uninstrumented version of it.
17 #![feature(core_intrinsics)]
19 #![allow(invalid_value)]
21 use std::hint::black_box;
22 use std::mem::MaybeUninit;
26 fn random() -> [isize; 32] {
27 let r = MaybeUninit::uninit();
28 // Avoid optimizing everything out.
29 unsafe { std::intrinsics::volatile_load(r.as_ptr()) }
34 fn xor(a: &[isize]) -> isize {
43 fn main(_: isize, _: *const *const u8) -> isize {
44 let r = black_box(random as fn() -> [isize; 32])();