Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 堆栈溢出,采用0.13英寸的大型固定大小阵列_Arrays_Stack Overflow_Rust - Fatal编程技术网

Arrays 堆栈溢出,采用0.13英寸的大型固定大小阵列

Arrays 堆栈溢出,采用0.13英寸的大型固定大小阵列,arrays,stack-overflow,rust,Arrays,Stack Overflow,Rust,我希望与Rust专家一起验证这个简单的Rust程序(Linux x86-64系统上的rustc 0.13.0-nightly): /* 运行时错误为: 任务“”已溢出其堆栈 非法指令(内核转储) */ fn main(){ 设l=[0u,…1_000_000u]; } 编译过程完美结束,没有错误,但在运行时程序失败,错误显示在代码注释中 Rust中的固定大小数组的维数是否有限制,或者这是编译器中的某个错误?Rust的默认堆栈大小为2MiB,堆栈空间不足: fn main() { pri

我希望与Rust专家一起验证这个简单的Rust程序(Linux x86-64系统上的rustc 0.13.0-nightly):

/*
运行时错误为:
任务“”已溢出其堆栈
非法指令(内核转储)
*/
fn main(){
设l=[0u,…1_000_000u];
}
编译过程完美结束,没有错误,但在运行时程序失败,错误显示在代码注释中


Rust中的固定大小数组的维数是否有限制,或者这是编译器中的某个错误?

Rust的默认堆栈大小为2MiB,堆栈空间不足:

fn main() {
    println!("min_stack = {}", std::rt::min_stack());
}
要分配该大小的数组,必须使用
box
在堆上分配它:

fn main() {
    let l = box [0u, ..1_000_000u];
}
fn main() {
    let l = box [0u, ..1_000_000u];
}