rust/tests/ui/sanitizer/leak.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
405 B
Rust
Raw Normal View History

//@ needs-sanitizer-support
//@ needs-sanitizer-leak
//
//@ compile-flags: -Z sanitizer=leak -O
//
//@ run-fail
//@ error-pattern: LeakSanitizer: detected memory leaks
use std::hint::black_box;
2016-12-30 04:28:11 +00:00
use std::mem;
fn main() {
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
}