2 // ignore-emscripten no threads
5 // Tests that the `vec!` macro does not overflow the stack when it is
6 // given data larger than the stack.
8 // FIXME(eddyb) Improve unoptimized codegen to avoid the temporary,
9 // and thus run successfully even when compiled at -C opt-level=0.
11 const LEN: usize = 1 << 15;
13 use std::thread::Builder;
16 assert!(Builder::new().stack_size(LEN / 2).spawn(|| {
17 // FIXME(eddyb) this can be vec![[0: LEN]] pending
18 // https://llvm.org/bugs/show_bug.cgi?id=28987
19 let vec = vec![unsafe { std::mem::zeroed::<[u8; LEN]>() }];
20 assert_eq!(vec.len(), 1);
21 }).unwrap().join().is_ok());