Skip to content

ICE with a fixed-size array of unsized elements #19201

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
apasel422 opened this issue Nov 21, 2014 · 3 comments
Closed

ICE with a fixed-size array of unsized elements #19201

apasel422 opened this issue Nov 21, 2014 · 3 comments
Labels
A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@apasel422
Copy link
Contributor

foo.rs:

#![crate_type = "lib"]
fn foo(a: [[u8], ..5]) {}

Compilation output:

> rustc --version=verbose
rustc 0.13.0-nightly (770378a31 2014-11-20 23:02:01 +0000)
binary: rustc
commit-hash: 770378a313a573776b16237a46b75bafa49072c1
commit-date: 2014-11-20 23:02:01 +0000
host: x86_64-unknown-linux-gnu
release: 0.13.0-nightly
> RUST_BACKTRACE=1 rustc -g foo.rs
error: internal compiler error: trying to take the sizing type of [[u8], ..5], an unsized type
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
task 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/diagnostic.rs:180

stack backtrace:
   1:     0x7f20abdc19c0 - rt::backtrace::imp::write::h38e72df4f68c2a0fB9s
   2:     0x7f20abdc4b60 - failure::on_fail::hfed62fa5028805c5uwt
   3:     0x7f20ac58ac80 - unwind::begin_unwind_inner::hd2440d158cff1c59nbd
   4:     0x7f20a9c520d0 - unwind::begin_unwind::h17290044112077471032
   5:     0x7f20a9c52800 - diagnostic::Handler::bug::h8fa91ae0c865994546F
   6:     0x7f20aac633b0 - session::Session::bug::h05a03c91b32e6800Kv1
   7:     0x7f20ac943230 - trans::type_of::sizing_type_of::h3534ab6bd94e52d0qmp
   8:     0x7f20ac9532a0 - trans::datum::Datum<'tcx, K>::shallow_copy_raw::h16566536734899422380
   9:     0x7f20ac9e0530 - trans::_match::store_arg::h3d2ddccad4775a94Qdy
  10:     0x7f20ac9e14b0 - trans::base::trans_closure::h427ba3d717d7f5ba7Au
  11:     0x7f20ac922890 - trans::base::trans_fn::h63d2777387d1a1cfXMu
  12:     0x7f20ac91f960 - trans::base::trans_item::h61310fa89585fcd9H8u
  13:     0x7f20ac9ec290 - trans::base::trans_crate::h80c040a30f021e9016v
  14:     0x7f20aca969f0 - driver::driver::phase_4_translate_to_llvm::h49b60a5096822567npS
  15:     0x7f20aca83c70 - driver::driver::compile_input::h56e37c9f95bced56dWR
  16:     0x7f20acb08560 - driver::run_compiler::hae38ed40c1a5e42bHUT
  17:     0x7f20acb08450 - driver::run::closure.59803
  18:     0x7f20ac915000 - task::TaskBuilder<S>::try_future::closure.39059
  19:     0x7f20ac914df0 - task::TaskBuilder<S>::spawn_internal::closure.39030
  20:     0x7f20ace28b10 - task::NativeSpawner.Spawner::spawn::closure.2471
  21:     0x7f20ac5e34c0 - rust_try_inner
  22:     0x7f20ac5e34b0 - rust_try
  23:     0x7f20ac5885e0 - unwind::try::h13cddac141b4f78fIZc
  24:     0x7f20ac588470 - task::Task::run::hafaf90f81703a435y5b
  25:     0x7f20ace28850 - task::NativeSpawner.Spawner::spawn::closure.2397
  26:     0x7f20ac589c90 - thread::thread_start::hda75e847cb45320fEqc
  27:     0x7f20a6e3afe0 - start_thread
  28:     0x7f20ac250819 - __clone
  29:                0x0 - <unknown>

This only happens when -g is specified, and is possibly related to #18866.

@kmcallister kmcallister added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-DSTs Area: Dynamically-sized types (DSTs) labels Nov 23, 2014
@erickt
Copy link
Contributor

erickt commented Jan 12, 2015

Visiting for triage. I've updated the code to:

#![crate_type = "lib"]
fn foo(a: [[u8]; 5]) {}

But it still ICE's with:

bad2.rs:2:1: 2:24 warning: function is never used: `foo`, #[warn(dead_code)] on by default
bad2.rs:2 fn foo(a: [[u8]; 5]) {}
          ^~~~~~~~~~~~~~~~~~~~~~~
bad2.rs:2:8: 2:9 warning: unused variable: `a`, #[warn(unused_variables)] on by default
bad2.rs:2 fn foo(a: [[u8]; 5]) {}
                 ^
error: internal compiler error: trying to take the sizing type of [u8], an unsized type
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 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:182

stack backtrace:
   1:        0x1127f14b5 - sys::backtrace::write::h64ca2fb259c4ae97lCt
   2:        0x11281394f - failure::on_fail::h64ff5ae6887860cc0Hz
   3:        0x11277f5ca - rt::unwind::begin_unwind_inner::h1d4bc098fd350446Qpz
   4:        0x1104930b7 - rt::unwind::begin_unwind::h1123425023578864118
   5:        0x110493a28 - diagnostic::Handler::bug::h6d2bfe842975d6e0tWF
   6:        0x10fa93788 - session::Session::bug::h5da8d79b0a6f5276iRq
   7:        0x10f1ca848 - trans::type_of::sizing_type_of::h9a9144f41b95ef26nUo
   8:        0x10f1c9bb4 - trans::type_of::sizing_type_of::h9a9144f41b95ef26nUo
   9:        0x10f1de841 - trans::common::type_is_immediate::h6bb1c0a049852e45tUk
  10:        0x10f25c889 - trans::type_of::type_of_rust_fn::hbbe004d99dfebef2xQo
  11:        0x10f2640e1 - trans::base::decl_rust_fn::h1e048b4bd74ce022s1r
  12:        0x10f27561e - trans::base::register_fn::h0ee69c538bdaf7b2dEu
  13:        0x10f192908 - trans::base::get_item_val::h697b171366de28ecc1u
  14:        0x10f18fce7 - trans::base::trans_item::hdbddd5abd5742b0cEwu
  15:        0x10f27902c - trans::base::trans_crate::h6077c32a4f7ba4e9lsv
  16:        0x10f035b3e - driver::phase_4_translate_to_llvm::ha92297f2357a645fPFa
  17:        0x10f011f4b - driver::compile_input::h31580cbd7ea87613xba
  18:        0x10f0dcfda - monitor::unboxed_closure.22557
  19:        0x10f0db735 - thunk::F.Invoke<A, R>::invoke::h6367419564961841226
  20:        0x10f0da510 - rt::unwind::try::try_fn::h7763956589852599824
  21:        0x11287a2a9 - rust_try_inner
  22:        0x11287a296 - rust_try
  23:        0x10f0dac0c - thunk::F.Invoke<A, R>::invoke::h16724184168577887652
  24:        0x112801154 - sys::thread::thread_start::hbd8f2f8bdd3a3baadrw
  25:     0x7fff9358c2fc - _pthread_body
  26:     0x7fff9358c279 - _pthread_body

@vadimcn
Copy link
Contributor

vadimcn commented Jan 23, 2015

Another repro:

static x: u8 = (*b"12345")[1];
fn main() {}

@apasel422
Copy link
Contributor Author

Neither of the following snippets cause an ICE as of rustc 1.0.0-nightly (083b8a404 2015-04-05) (built 2015-04-05):

#![crate_type = "lib"]
fn foo(a: [[u8]; 5]) {}
static x: u8 = (*b"12345")[1];
fn main() {}

lnicola added a commit to lnicola/rust that referenced this issue Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants