Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

println! of an out of bound element in an array segfaults on Mac OS Yosemite #52139

Closed
avtomat2023 opened this issue Jul 7, 2018 · 1 comment

Comments

@avtomat2023
Copy link

// array_out_of_bound.rs
fn main() {
    let a = [1];
    println!("{}", a[1]);
}

This program segfaults on Mac OS 10.10.5.

$ rustc --version
rustc 1.27.0 (3eda71b00 2018-06-19)
$ rustc array_out_of_bound.rs 
$ ./array_out_of_bound 
zsh: segmentation fault  ./array_out_of_bound

I tried compiling and executing on Debian 9.4, which printed panic message correctly.

Without println!, Mac OS prints panic message.

// array_out_of_bound.rs
fn main() {
    let a = [1];
    a[1];
}
$ rustc array_out_of_bound.rs 
$ ./array_out_of_bound 
thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', array_out_of_bound.rs:3:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
@sfackler
Copy link
Member

sfackler commented Jul 7, 2018

Duplicate of #51758

@sfackler sfackler marked this as a duplicate of #51758 Jul 7, 2018
@sfackler sfackler closed this as completed Jul 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants