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

Panic when trying to create two static slices of an array #21891

Closed
LeoTestard opened this issue Feb 3, 2015 · 1 comment
Closed

Panic when trying to create two static slices of an array #21891

LeoTestard opened this issue Feb 3, 2015 · 1 comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@LeoTestard
Copy link
Contributor

The following code raises an panic in librustc_trans:

static foo_1: [uint; 3] = [1, 2, 3];

static slice_1: &'static [uint] = &foo_1;
static slice_2: &'static [uint] = &foo_1;

fn main() {} 
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'assertion failed: cx.const_globals().borrow_mut().insert(llptr as int, llconst).is_none()', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/librustc_trans/trans/consts.rs:244

The error happens on this assertion.

Just taking references to the array (&'static [uint; 3]) works, so I think this is specific to slices.
I don't see why this code should be invalid, but even if it is, it should be handled better.

@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 3, 2015
@LeoTestard
Copy link
Contributor Author

Fixed by #21986.

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

2 participants