I'm trying to create fixed-size array in stack, but it shows `stack overflow`

, then I change it to heap (it said to allocate in the heap we must use `box`

), but it still shows an `stack overflow`

.

```
fn new_gap(gap: usize) -> usize {
let ngap = ((gap as f64) / 1.3) as usize;
if ngap == 9 || ngap == 10 { return 11 }
if ngap < 1 { return 1 }
return ngap
}
fn comb_sort(a: &mut Box<[f64]>) { // previously: [f64]
let xlen = a.len();
let mut gap = xlen;
let mut swapped : bool;
let mut temp : f64;
loop {
swapped = false;
gap = new_gap(gap);
for i in 0..(xlen-gap) {
if a[i] > a[i+gap] {
swapped = true;
temp = a[i];
a[i] = a[i+gap];
a[i+gap] = temp;
}
}
if !(gap > 1 || swapped) { break }
}
}
const N : usize = 10000000;
fn main() {
let mut arr: Box<[f64]> = Box::new([0.0; N]); // previously: [f64; N] = [0.0; N];
for z in 0..(N) { arr[z] = (N - z) as f64; }
comb_sort(&mut arr);
for z in 1..(N) { if arr[z] < arr[z-1] { print!("!") } }
}
```

The output:

```
thread '<main>' has overflowed its stack
Illegal instruction (core dumped)
```

I know that my stack size is not enough when using stack (same as c++ when creating non-heap array that too big inside function), but this code is using heap but still shows stack overflow, what's really wrong with this code anyway? (note: this is not a homework). I'm using `rustc 1.0.0-dev`