2020-01-16 00:00:00 +00:00
|
|
|
//@ needs-sanitizer-support
|
2020-06-05 00:00:00 +00:00
|
|
|
//@ needs-sanitizer-leak
|
2020-01-16 00:00:00 +00:00
|
|
|
//
|
|
|
|
//@ compile-flags: -Z sanitizer=leak -O
|
|
|
|
//
|
|
|
|
//@ run-fail
|
|
|
|
//@ error-pattern: LeakSanitizer: detected memory leaks
|
|
|
|
|
2020-01-15 00:00:00 +00:00
|
|
|
use std::hint::black_box;
|
2016-12-30 04:28:11 +00:00
|
|
|
use std::mem;
|
|
|
|
|
|
|
|
fn main() {
|
2020-01-15 00:00:00 +00:00
|
|
|
for _ in 0..10 {
|
|
|
|
let xs = vec![1, 2, 3];
|
|
|
|
// Prevent compiler from removing the memory allocation.
|
|
|
|
let xs = black_box(xs);
|
|
|
|
mem::forget(xs);
|
|
|
|
}
|
2016-12-30 04:28:11 +00:00
|
|
|
}
|