Closed
Description
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.