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

ICE: index out of bounds: the len is 0 but the index is 0 #16048

Closed
mrmonday opened this issue Jul 28, 2014 · 2 comments · Fixed by #18099
Closed

ICE: index out of bounds: the len is 0 but the index is 0 #16048

mrmonday opened this issue Jul 28, 2014 · 2 comments · Fixed by #18099
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@mrmonday
Copy link
Contributor

Compiler (modified, but verified issue on http://play.rust-lang.org/):

rustc 0.12.0-pre (a4a2bf566fd41ec35226d6bacee8dba45a196a60 2014-07-15 15:37:44 +0100)
binary: rustc
commit-hash: a4a2bf566fd41ec35226d6bacee8dba45a196a60
commit-date: 2014-07-15 15:37:44 +0100
host: x86_64-unknown-linux-gnu
release: 0.12.0-pre

Source:

trait NoLifetime {
    fn get<'p, T : Test<'p>>(&self) -> T;
}

trait Test<'p> {
    fn new(buf: &'p mut [u8]) -> Self;
}

struct Foo<'a> {
    //a: int
    buf: &'a mut [u8],
}

impl<'a> Test<'a> for Foo<'a> {
    fn new(buf: &'a mut [u8]) -> Foo<'a> {
        Foo { buf: buf }
    }
}

impl<'a> NoLifetime for Foo<'a> {
    fn get<'p, T : Test<'a>>(&self) -> T {
        return *self as T;
    }
}

fn main() {

}

Output:

ice.rs:22:16: 22:26 error: non-scalar cast: `Foo<'a>` as `T`
ice.rs:22         return *self as T;
                         ^~~~~~~~~~
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. 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' failed at 'index out of bounds: the len is 0 but the index is 0', /home/robert/rust/src/librustc/middle/subst.rs:405

stack backtrace:
   1:     0x7f59dfd89750 - rt::backtrace::imp::write::h079eed8b4183d226t7p
   2:     0x7f59dfd8cfb0 - failure::on_fail::hf0a1aa68f05b9f3eIsq
   3:     0x7f59e056aba0 - unwind::begin_unwind_inner::hc7e7531ea03bf63641d
   4:     0x7f59e056a7f0 - unwind::begin_unwind_fmt::h3f3e62847673bb96xZd
   5:     0x7f59e056a7b0 - rust_begin_unwind
   6:     0x7f59e05ad170 - failure::begin_unwind::h953da15ca40ac352Gsj
   7:     0x7f59e05b0a20 - failure::fail_bounds_check::h6d9ef56460fb3496Sqj
   8:     0x7f59e09dbd10 - middle::ty_fold::ty..Region.TypeFoldable::fold_with::h8821839781562148557
   9:     0x7f59e09dbcd0 - middle::ty_fold::VecPerParamSpace<T>.TypeFoldable::fold_with::closure.$x22closure$x22$LP$96970$RP$
  10:     0x7f59e09da7e0 - middle::subst::VecPerParamSpace<T>::map::h4074482880838128682
  11:     0x7f59e09da610 - middle::ty_fold::TypeFolder::fold_substs::h9918967593543296047
  12:     0x7f59e0b42440 - middle::subst::T.Subst::subst_spanned::h18065759743740398268
  13:     0x7f59e0c82b20 - middle::typeck::check::compare_impl_method::h45f28e9e009d76dcfkh
  14:     0x7f59e0c6dfd0 - middle::typeck::check::check_item::h61093964faedb0786Xg
  15:     0x7f59e0c74b80 - middle::typeck::check::check_item_types::hc151b158b03a27ccdqg
  16:     0x7f59e0de5430 - middle::typeck::check_crate::hfaef0151d1c472f5gMG
  17:     0x7f59e116dda0 - driver::driver::phase_3_run_analysis_passes::h56b081ce642bbf64vAr
  18:     0x7f59e1169640 - driver::driver::compile_input::h247fca9f7ba62049wmr
  19:     0x7f59e1222330 - driver::run_compiler::hfdcb4e3d769c700eBsu
  20:     0x7f59e1222240 - driver::main_args::closure.$x22closure$x22$LP$132588$RP$
  21:     0x7f59e1235e20 - task::TaskBuilder<S>::try_future::closure.$x22closure$x22$LP$133737$RP$
  22:     0x7f59e1235bb0 - task::TaskBuilder<S>::spawn_internal::closure.$x22closure$x22$LP$133714$RP$
  23:     0x7f59e1bd2960 - task::spawn_opts::closure.$x22closure$x22$LP$8449$RP$
  24:     0x7f59e05c1170 - rust_try
  25:     0x7f59e0567c30 - unwind::try::hfdf5af0beedee967tQd
  26:     0x7f59e0567990 - task::Task::run::hfe12a6f8839748ddP1c
  27:     0x7f59e1bd2750 - task::spawn_opts::closure.$x22closure$x22$LP$8395$RP$
  28:     0x7f59e0569c10 - thread::thread_start::h203fd40fba58c73dnod
  29:     0x7f59df80aea0 - start_thread
  30:     0x7f59e0229999 - __clone
  31:                0x0 - <unknown>
@mahkoh
Copy link
Contributor

mahkoh commented Oct 10, 2014

No longer valid.

@alexcrichton
Copy link
Member

Flagging as needstest

@alexcrichton alexcrichton added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 11, 2014
bors added a commit that referenced this issue Oct 18, 2014
Closes #9249.
Closes #13105.
Closes #13837.
Closes #13847.
Closes #15207.
Closes #15261.
Closes #16048. 
Closes #16098.
Closes #16256.
Closes #16562.
Closes #16596.
Closes #16709.
Closes #16747.
Closes #17025.
Closes #17121.
Closes #17450.
Closes #17636.
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 11, 2023
fix: Fix concat_bytes! expansion emitting an identifier

Fixes rust-lang/rust-analyzer#16046 (note that this has always been broken)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants