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

Assigning a mutable owned pointer to itself causes a segfault #13201

Closed
paigeruten opened this issue Mar 29, 2014 · 3 comments
Closed

Assigning a mutable owned pointer to itself causes a segfault #13201

paigeruten opened this issue Mar 29, 2014 · 3 comments
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@paigeruten
Copy link

The following program causes a segmentation fault when dereferencing x.

fn main() {
    let mut x: ~int = ~1;
    x = x;
    println("-");
    let y = *x;
    println("-");
}

My output:

jeremy@slupchik:~/tmp$ rustc -v
rustc 0.9
host: x86_64-unknown-linux-gnu
jeremy@slupchik:~/tmp$ rustc bug.rs
bug.rs:5:9: 5:10 warning: unused variable: `y`, #[warn(unused_variable)] on by default
bug.rs:5     let y = *x;
                 ^
jeremy@slupchik:~/tmp$ ./bug
-
Segmentation fault
@huonw
Copy link
Member

huonw commented Mar 30, 2014

Thanks for the report. I'm pretty sure this is fixed on master (I don't have access to a compiler to verify right now, so I won't close).

@sfackler
Copy link
Member

Yep, I just verified that it runs correctly on 3eb3a02.

@alexcrichton
Copy link
Member

Closing as a dupe of #3290, which I believe has tests already checked in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

4 participants