]>
Commit | Line | Data |
---|---|---|
5e7ed085 FG |
1 | // compile-flags: -Z oom=panic |
2 | // run-pass | |
3 | // no-prefer-dynamic | |
4 | // needs-unwind | |
5 | // only-linux | |
6 | ||
5e7ed085 FG |
7 | use std::hint::black_box; |
8 | use std::mem::forget; | |
9 | use std::panic::catch_unwind; | |
10 | ||
11 | fn main() { | |
12 | let panic = catch_unwind(|| { | |
13 | // This is guaranteed to exceed even the size of the address space | |
14 | for _ in 0..16 { | |
15 | // Truncates to a suitable value for both 32-bit and 64-bit targets. | |
16 | let alloc_size = 0x1000_0000_1000_0000u64 as usize; | |
17 | forget(black_box(vec![0u8; alloc_size])); | |
18 | } | |
19 | }); | |
20 | assert!(panic.is_err()); | |
21 | } |