2020-01-15 18:00:00 -06:00
|
|
|
// needs-sanitizer-support
|
2020-06-04 19:00:00 -05:00
|
|
|
// needs-sanitizer-leak
|
2020-01-15 18:00:00 -06:00
|
|
|
//
|
|
|
|
// compile-flags: -Z sanitizer=leak -O
|
|
|
|
//
|
|
|
|
// run-fail
|
|
|
|
// error-pattern: LeakSanitizer: detected memory leaks
|
|
|
|
|
2020-01-14 18:00:00 -06:00
|
|
|
use std::hint::black_box;
|
2016-12-29 22:28:11 -06:00
|
|
|
use std::mem;
|
|
|
|
|
|
|
|
fn main() {
|
2020-01-14 18:00:00 -06: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-29 22:28:11 -06:00
|
|
|
}
|