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

ICE with mut reference in static mut #26263

Closed
eefriedman opened this issue Jun 12, 2015 · 5 comments
Closed

ICE with mut reference in static mut #26263

eefriedman opened this issue Jun 12, 2015 · 5 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@eefriedman
Copy link
Contributor

Testcase:

static mut TEST: [isize; 1] = [1];
static mut TEST2: &'static mut [isize] = unsafe { &mut TEST };
fn main() {
    println!("{}", unsafe { TEST2[0] });
}

Produces:

<anon>:2:56: 2:60 error: internal compiler error: expected a const, fn, struct, or variant def
<anon>:2 static mut TEST2: &'static mut [isize] = unsafe { &mut TEST };
                                                                ^~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:176
@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jun 13, 2015
@arielb1
Copy link
Contributor

arielb1 commented Jun 14, 2015

I think the original intent was to allow references to slices &mut [1,2,3].

@arielb1
Copy link
Contributor

arielb1 commented Jun 14, 2015

What level of this should be allowed? We don't borrowck statics, so you can do (&mut A, &mut A).

@eefriedman
Copy link
Contributor Author

I would figure if someone is willing to use unsafe blocks to build a static mut variable, we should just let them shoot themselves in the foot. You can construct a static mut variable containing (&mut A, &mut A) at runtime anyway.

@apasel422
Copy link
Contributor

Triage: Still an issue.

@steveklabnik
Copy link
Member

This ICE seems to be fixed on

rustc 1.12.0-nightly (b30eff7ba 2016-08-05)

I have a hunch that this is due to MIR being turned on, though I'm not sure. Please let me know if this still ICEs for you, but closing for now 🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants