]> git.lizzy.rs Git - rust.git/blob - tests/ui/codegen/issue-28950.rs
Rollup merge of #105526 - Xiretza:iter-from-generator-derive, r=scottmcm
[rust.git] / tests / ui / codegen / issue-28950.rs
1 // run-pass
2 // ignore-emscripten no threads
3 // compile-flags: -O
4
5 // Tests that the `vec!` macro does not overflow the stack when it is
6 // given data larger than the stack.
7
8 // FIXME(eddyb) Improve unoptimized codegen to avoid the temporary,
9 // and thus run successfully even when compiled at -C opt-level=0.
10
11 const LEN: usize = 1 << 15;
12
13 use std::thread::Builder;
14
15 fn main() {
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());
22 }