]> git.proxmox.com Git - rustc.git/blame - src/test/ui/oom_unwind.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / oom_unwind.rs
CommitLineData
5e7ed085
FG
1// compile-flags: -Z oom=panic
2// run-pass
3// no-prefer-dynamic
4// needs-unwind
5// only-linux
6
5e7ed085
FG
7use std::hint::black_box;
8use std::mem::forget;
9use std::panic::catch_unwind;
10
11fn 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}