1 // Ensure we appropriately error instead of overflowing a calculation when creating a new Alloc
5 // compile-flags: -C opt-level=3
6 // error-pattern: index out of bounds: the len is 0 but the index is 16777216
7 // ignore-wasm no panic or subprocess support
8 // ignore-emscripten no panic or subprocess support
10 fn do_test(x: usize) {
11 let arr = vec![vec![0u8; 3]];
13 let mut z = Vec::new();
17 z.extend(std::iter::repeat(0).take(x));
19 let b = (y + 1) * x - 1;
20 let slice = &arr_ref[a..b];
21 eprintln!("{} {} {} {}", a, b, arr_ref.len(), slice.len());
22 eprintln!("{:?}", slice[1 << 24]);