File tree 2 files changed +10
-7
lines changed
src/test/run-make-fulldeps/sanitizer-leak
2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 1
1
-include ../tools.mk
2
2
3
3
# needs-sanitizer-support
4
- # only-linux
5
- # only-x86_64
6
- # ignore-test
7
- # FIXME(#46126) ThinLTO for libstd broke this test
8
4
9
5
all :
10
- $(RUSTC ) -C opt-level=1 -g -Z sanitizer=leak -Z print-link-args leak.rs | $(CGREP ) rustc_rt.lsan
6
+ $(RUSTC ) -O -Z sanitizer=leak -Z print-link-args leak.rs | $(CGREP ) rustc_rt.lsan
11
7
$(TMPDIR ) /leak 2>&1 | $(CGREP ) ' detected memory leaks'
Original file line number Diff line number Diff line change
1
+ #![ feature( test) ]
2
+
3
+ use std:: hint:: black_box;
1
4
use std:: mem;
2
5
3
6
fn main ( ) {
4
- let xs = vec ! [ 1 , 2 , 3 , 4 ] ;
5
- mem:: forget ( xs) ;
7
+ for _ in 0 ..10 {
8
+ let xs = vec ! [ 1 , 2 , 3 ] ;
9
+ // Prevent compiler from removing the memory allocation.
10
+ let xs = black_box ( xs) ;
11
+ mem:: forget ( xs) ;
12
+ }
6
13
}
You can’t perform that action at this time.
0 commit comments