Skip to content

ICE when assigning to a static mut #47789

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

Closed
nikomatsakis opened this issue Jan 26, 2018 · 3 comments
Closed

ICE when assigning to a static mut #47789

nikomatsakis opened this issue Jan 26, 2018 · 3 comments
Assignees
Labels
A-NLL Area: Non-lexical lifetimes (NLL) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

This code assigning to a static mut causes an ICE when run with feature(nll):

#![feature(nll)]

static y: u32 = 22;
static mut x: &'static u32 = &y;

fn foo() {
    unsafe { x = &y; }
}

fn main() { }

On the playground, I get this:

error: internal compiler error: unexpected panic

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: rustc 1.25.0-nightly (9fd7da904 2018-01-25) running on x86_64-unknown-linux-gnu

thread 'rustc' panicked at 'internal error: entered unreachable code', librustc_mir/dataflow/impls/borrows.rs:400:50
note: Run with `RUST_BACKTRACE=1` for a backtrace.
@nikomatsakis nikomatsakis added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-NLL Area: Non-lexical lifetimes (NLL) WG-compiler-nll labels Jan 26, 2018
@nikomatsakis nikomatsakis added this to the NLL: Valid code works milestone Jan 26, 2018
@cuviper cuviper added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ C-bug Category: This is a bug. labels Jan 27, 2018
@ritiek
Copy link
Member

ritiek commented Jan 27, 2018

cc @pnkfelix who wrote related code in #46887.

@Aaron1011
Copy link
Member

I'd like to work on this.

Aaron1011 added a commit to Aaron1011/rust that referenced this issue Jan 31, 2018
is_unsafe_place only filters out statics in the rhs, not the lhs. Since
it's possible to reach that 'Place::Static', we handle statics the same
way as we do locals.

Fixes rust-lang#47789
@nikomatsakis
Copy link
Contributor Author

@Aaron1011 great =)

kennytm added a commit to kennytm/rust that referenced this issue Feb 2, 2018
…sakis Fix ICE when assigning references to a static mut with NLL is_unsafe_place only filters out statics in the rhs, not the lhs. Since it's possible to reach that 'Place::Static', we handle statics the same way as we do locals. Fixes rust-lang#47789
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NLL Area: Non-lexical lifetimes (NLL) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants