The `nums` array is allocated on the stack and is 8 MB (assuming you're on a 64 bit platform).
On Wed Nov 26 2014 at 8:23:08 PM Ben Wilson <[email protected]> wrote: > Hey folks, I've started writing some rust code lately and run into weird > behavior when benchmarking. When running > > https://gist.github.com/benwilson512/56f84ffffd4625f11feb > > #[bench] > fn test_overflow(b: &mut Bencher) { > let nums = [0i, ..1000000]; > b.iter(|| { > let mut x = 0i; > for i in range(0, nums.len()) { > x = nums[i]; > } > }); > } > > I get "task '<main>' has overflowed its stack" pretty much immediately when > running cargo bench. Ordinarily I'd expect to see that error when doing > recursion, but I can't quite figure out why it's showing up here. What am I > missing? > > Thanks! > > - Ben > > _______________________________________________ > Rust-dev mailing list > [email protected] > https://mail.mozilla.org/listinfo/rust-dev >
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
