summary refs log tree commit diff
path: root/src/test/ui/sanitize/leak.rs
blob: 5c2f2cb4e868bb0012a960f21a61e7f85f044017 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// needs-sanitizer-support
// only-x86_64
//
// compile-flags: -Z sanitizer=leak -O
//
// run-fail
// error-pattern: LeakSanitizer: detected memory leaks

#![feature(test)]

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);
    }
}