Skip to content

ICE: using variable to index on const ref to static array #22540

@mathall

Description

@mathall
const TEST: &'static [usize] = &[0];

fn main() {
  let n = 0;
  TEST[n];
}
stack backtrace:
   1:        0x11112f7c3 - sys::backtrace::write::h758e31f43edeba51YoB
   2:        0x11115d525 - panicking::on_panic::h64e08c3ac337d99aAGK
   3:        0x11108eb28 - rt::unwind::begin_unwind_inner::hbe305651b0fb4548QnK
   4:        0x10d5c0f55 - rt::unwind::begin_unwind::h11966735602550941006
   5:        0x10d63f95f - trans::datum::Datum<'tcx, Expr>::to_lvalue_datum::ha6e7f9c51770741dbYf
   6:        0x10d674a4c - trans::expr::trans_index::h24f970edf801dea70Ei
   7:        0x10d660bc9 - trans::expr::trans_unadjusted::h60994bf53fc1f141mqi
   8:        0x10d612beb - trans::expr::trans_into::h985f6b8ade1f0862jGh
   9:        0x10d611a1b - trans::controlflow::trans_stmt_semi::hfa4945e6389f144c6de
  10:        0x10d613683 - trans::controlflow::trans_block::h24750b7c4a4226dcXee
  11:        0x10d6e9339 - trans::base::trans_closure::hc0a2577d0b8ff90aFiu
  12:        0x10d5fd9b6 - trans::base::trans_fn::hdc6e33d20e22c94bWtu
  13:        0x10d5f8d1d - trans::base::trans_item::h64db2b88677453d4PSu
  14:        0x10d6efd1c - trans::base::trans_crate::h414eeb210dd461c6fQv
  15:        0x10d47f9c8 - driver::phase_4_translate_to_llvm::h83cf15bb7798b7baiPa
  16:        0x10d4598a6 - driver::compile_input::h5f42c7591ab1e8afEba
  17:        0x10d533284 - run_compiler::h569cf29d11ba11b9Rbc
  18:        0x10d530305 - thunk::F.Invoke<A, R>::invoke::h584465160991669811
  19:        0x10d52efa0 - rt::unwind::try::try_fn::h36519155281163913
  20:        0x1111d7329 - rust_try_inner
  21:        0x1111d7316 - rust_try
  22:        0x10d52f699 - thunk::F.Invoke<A, R>::invoke::h10026663398983596708
  23:        0x111145d13 - sys::thread::thread_start::h0953ffc55eda2123CWF
  24:     0x7fff98c93268 - _pthread_body
  25:     0x7fff98c931e5 - _pthread_body

There are open bugs with similar backtraces, but otherwise the circumstances seem quite different.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions