summaryrefslogtreecommitdiffstats
path: root/tests/ui/sanitize/leak.rs
blob: cbb44ae8acd60a8a0922b9f0facf9e5abbc6656c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// 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;
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);
    }
}