Skip to content

ICE: assertion failed: prev_const.is_none() || prev_const == Some(llconst) #24644

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
bytwise opened this issue Apr 20, 2015 · 4 comments · Fixed by #25797
Closed

ICE: assertion failed: prev_const.is_none() || prev_const == Some(llconst) #24644

bytwise opened this issue Apr 20, 2015 · 4 comments · Fixed by #25797
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@bytwise
Copy link
Contributor

bytwise commented Apr 20, 2015

Code

trait Trait {}

struct Bar;
impl Trait for Bar {}

fn main() {
    let x: &[&Trait] = &[{ &Bar }];
}

Output

main.rs:7:9: 7:10 warning: unused variable: `x`, #[warn(unused_variables)] on by default
main.rs:7     let x: &[&Trait] = &[{ &Bar }];
                  ^
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'assertion failed: prev_const.is_none() || prev_const == Some(llconst)', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc_trans/trans/consts.rs:321

stack backtrace:
   1:        0x1054eb5cf - sys::backtrace::write::h9137c695ab290a14WRs
   2:        0x1054f3b82 - panicking::on_panic::h0ae3cf09aff03bc05Pw
   3:        0x1054a9d15 - rt::unwind::begin_unwind_inner::h36b4206cb80fb108Oxw
   4:        0x102149fcf - rt::unwind::begin_unwind::h6767503471583286242
   5:        0x1021c082c - trans::consts::const_expr::h1bbfa5560b941f32nvs
   6:        0x102224922 - vec::Vec<T>.FromIterator<T>::from_iter::h7466739370638199104
   7:        0x10221baea - trans::consts::const_expr_unadjusted::hd675727493ff08eezLs
   8:        0x1021bfff7 - trans::consts::const_expr::h1bbfa5560b941f32nvs
   9:        0x10221dc67 - trans::consts::const_expr_unadjusted::hd675727493ff08eezLs
  10:        0x1021bfff7 - trans::consts::const_expr::h1bbfa5560b941f32nvs
  11:        0x10221a9f9 - trans::consts::get_const_expr_as_global::h2f40511a988c5876yss
  12:        0x10218f6ca - trans::expr::trans::h959669806b495bbffdA
  13:        0x1022314e0 - trans::expr::trans_into::h43738e587d521f35W6z
  14:        0x1022b4e21 - trans::_match::mk_binding_alloca::h2459388509959927399
  15:        0x1021a09b9 - trans::base::init_local::h8acf9c70632535fdNVg
  16:        0x1021b1453 - trans::controlflow::trans_block::hb872ebbfd195606cZ2u
  17:        0x1021b0105 - trans::base::trans_closure::hbf7fcb6cfae5e775KCh
  18:        0x1021b1d9e - trans::base::trans_fn::hb08e54207cb8d8e6sNh
  19:        0x1021b5308 - trans::base::trans_item::h15647b08683789dbEbi
  20:        0x1021c40f0 - trans::base::trans_crate::hdfbb43ad3281f84dE0i
  21:        0x101c4fdde - driver::phase_4_translate_to_llvm::he9458af7df85ffb8lOa
  22:        0x101c28344 - driver::compile_input::h3c162f55ed6be3a5Qba
  23:        0x101cef853 - run_compiler::hae39edbb343296d3D4b
  24:        0x101ced37a - boxed::F.FnBox<A>::call_box::h1927805197202631788
  25:        0x101cec817 - rt::unwind::try::try_fn::h7355792964568869981
  26:        0x10557d998 - rust_try_inner
  27:        0x10557d985 - rust_try
  28:        0x101cecaf0 - boxed::F.FnBox<A>::call_box::h2359980489235781969
  29:        0x1054f26cd - sys::thread::create::thread_start::hfa406746e663ba1bNUv
  30:     0x7fff81be3267 - _pthread_body
  31:     0x7fff81be31e4 - _pthread_start


Rust Version

rustc 1.0.0-nightly (1284be404 2015-04-18) (built 2015-04-17)
binary: rustc
commit-hash: 1284be4044420bc4c41767284ae26be61a38d331
commit-date: 2015-04-18
build-date: 2015-04-17
host: x86_64-apple-darwin
release: 1.0.0-nightly
@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Apr 20, 2015
@Valloric
Copy link
Contributor

I'm getting the same ICE as well.

@Valloric
Copy link
Contributor

Possibly useful information: it's the braces around &Bar that are causing the ICE. This code compiles without an ICE:

trait Trait {}

struct Bar;
impl Trait for Bar {}

fn main() {
    let x: &[&Trait] = &[&Bar];
}

Putting braces around &Bar causes the ICE.

Tested on latest nightly.

Valloric added a commit to Valloric/nailgun that referenced this issue May 17, 2015
This is the specific ICE issue: rust-lang/rust#24644
@eddyb
Copy link
Member

eddyb commented May 26, 2015

The slice is superfluous:

trait Trait {}

struct Bar;
impl Trait for Bar {}

const FOO: &'static Trait = &Bar;
const BAR: &'static Trait = FOO;
fn main() { let x = BAR; }

The assertion is triggered by BAR, because it actually does unsizing from Trait to Trait and the logic for that is broken (it uses the wrong value as the "sized pointer").

@eddyb
Copy link
Member

eddyb commented May 26, 2015

Another example, from #25748:

pub struct UTF8Encoding;
pub const UTF_8: &'static UTF8Encoding = &UTF8Encoding;
pub trait Encoding {}
impl Encoding for UTF8Encoding {}
pub fn f() -> &'static Encoding { UTF_8 as &'static Encoding }

In this case, the explicit cast is redundant and there's an automatic unsizing from Encoding to Encoding, triggering the same broken logic.

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

Successfully merging a pull request may close this issue.

4 participants