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

compiler bug: const expr(...) of type X has size 20 instead of 24 #20074

Closed
conradkleinespel opened this issue Dec 20, 2014 · 2 comments
Closed
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@conradkleinespel
Copy link
Contributor

Hello every (reading this) 😃

I seem to have encountered a compiler bug. As explained in the bug report docs, I am reporting this here.

Here's my rustc version (on 64bits Linux Ubuntu 14.04):

rustc 0.13.0-nightly (193390d0e 2014-12-11 22:56:54 +0000)

I am compiling this through Cargo:

cargo 0.0.1-pre-nightly (0f6667c 2014-12-08 21:19:01 +0000)

Here's a backtrace of the error:

error: internal compiler error: const expr(81: Check::Chars('<', '\x00', '\x00', '\x00')) of type Check has size 20 instead of 24
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:188

stack backtrace:
   1:     0x7fcec950a500 - rt::backtrace::imp::write::heed5901f9756dd23BOx
   2:     0x7fcec950d740 - failure::on_fail::ha44d264deefff4481fy
   3:     0x7fcec915ef30 - unwind::begin_unwind_inner::h8d953f2c1d079705CJc
   4:     0x7fcec6bad040 - unwind::begin_unwind::h6666496483973781562
   5:     0x7fcec6bad8f0 - diagnostic::Handler::bug::h3a50c284fdf4e0a0baF
   6:     0x7fcec7763c90 - session::Session::bug::h961d19b73812d5bclMz
   7:     0x7fcec81efd40 - trans::consts::const_expr::hfa0dfd22263a486eY9n
   8:     0x7fcec81f8d20 - trans::consts::const_expr_unadjusted::closure.43393
   9:     0x7fcec81f7b60 - trans::expr::with_field_tys::h14927854885479319893
  10:     0x7fcec81f2800 - trans::consts::const_expr_unadjusted::h8c6ef2cbf874918a5lo
  11:     0x7fcec81efd40 - trans::consts::const_expr::hfa0dfd22263a486eY9n
  12:     0x7fcec81f2800 - trans::consts::const_expr_unadjusted::h8c6ef2cbf874918a5lo
  13:     0x7fcec81efd40 - trans::consts::const_expr::hfa0dfd22263a486eY9n
  14:     0x7fcec81f2800 - trans::consts::const_expr_unadjusted::h8c6ef2cbf874918a5lo
  15:     0x7fcec81efd40 - trans::consts::const_expr::hfa0dfd22263a486eY9n
  16:     0x7fcec814f120 - trans::base::get_item_val::h5e961c6ea5c9b50aGhv
  17:     0x7fcec814c020 - trans::base::trans_item::h567773db3b83315aeMu
  18:     0x7fcec82135a0 - trans::base::trans_mod::hc21a44b9f586bc03JRu
  19:     0x7fcec8217430 - trans::base::trans_crate::h03fccece3ec7cb85oIv
  20:     0x7fcec9946540 - driver::phase_4_translate_to_llvm::hb8e7de445fc1ade7VCa
  21:     0x7fcec992b260 - driver::compile_input::hf96889ff0bafd855pba
  22:     0x7fcec99c8070 - run_compiler::h9db34658886d7891EYb
  23:     0x7fcec99c7f60 - run::closure.21438
  24:     0x7fcec99d9970 - task::TaskBuilder::try_future::closure.22892
  25:     0x7fcec94e2980 - task::TaskBuilder::spawn_internal::closure.30605
  26:     0x7fcec915cbd0 - task::Task::spawn::closure.5728
  27:     0x7fcec91ba250 - rust_try_inner
  28:     0x7fcec91ba240 - rust_try
  29:     0x7fcec915ccb0 - unwind::try::hf2f7fcf7ecc46c43Tyc
  30:     0x7fcec915ca70 - task::Task::run::h911f3b3bbb0c433efKb
  31:     0x7fcec915c660 - task::Task::spawn::closure.5704
  32:     0x7fcec915e0b0 - thread::thread_start::h051da3e5b33a422fw1b
  33:     0x7fcec40480c0 - start_thread
  34:     0x7fcec8e22ec9 - __clone
  35:                0x0 - <unknown>

Could not compile `parser`.

Just in case it could help, here's the code I am trying to compile (the start of a HTML lexer with a state transition table):

// Lookahead of 3 symbols, which allows to see "!--" for a comment.

enum State {
    General,
    TagName,
    TagAttributeName,
    TagAttributeValue,
    Text,
    Doctype,
    Comment
}

enum Check {
    Function(fn(c1: char, c2: char, c3: char, c4: char) -> bool),
    Chars(char, char, char, char)
}

struct Transition {
    from: State,
    to: State,
    lookahead: u8,
    through: Check,
    save_char: bool,
    save_previous_token: bool
}

static transition_table: &'static [Transition] = &[
    Transition {
        from: State::General,
        to: State::TagName,
        lookahead: 1,
        through: Check::Chars('<', '\0', '\0', '\0'),
        save_char: false,
        save_previous_token: false,
    }
];

fn main() {
    let mut stdin = std::io::stdio::stdin();

    for line_result in stdin.lock().lines() {
        match line_result {
            Ok(line) => {
                let slice = line.as_slice().slice_to(line.len() - 1);
                println!("{}", slice);
            },
            Err(err) => {
                println!("{}", err);
                return;
            }
        }
    }
}

Hopefully, this can help. Please feel free to ask for more information if you need :-)

@conradkleinespel conradkleinespel changed the title const expr(81: Check::Chars('<', '\x00', '\x00', '\x00')) of type Check has size 20 instead of 24 const expr(...) of type X has size 20 instead of 24 Dec 20, 2014
@conradkleinespel conradkleinespel changed the title const expr(...) of type X has size 20 instead of 24 compiler bug: const expr(...) of type X has size 20 instead of 24 Dec 20, 2014
@conradkleinespel conradkleinespel changed the title compiler bug: const expr(...) of type X has size 20 instead of 24 compiler bug: const expr(...) of type X has size 20 instead of 24 Dec 20, 2014
@conradkleinespel conradkleinespel changed the title compiler bug: const expr(...) of type X has size 20 instead of 24 compiler bug: const expr(...) of type X has size 20 instead of 24 Dec 20, 2014
@nodakai
Copy link
Contributor

nodakai commented Dec 21, 2014

Seems like the enum tags are padded differently.

enum E {
    F(i64),
    C(i32, i32, i32, i32)
}

static T: &'static [E] = &[
    E::C(0,0,0,0)
];

fn main() { }
{ i8, i32, i32, i32, i32, [0 x i8] } { i8 1, i32 0, i32 0, i32 0, i32 0, [0 x i8] undef }
{ i8, [7 x i8], [2 x i64] } undef
error: internal compiler error: const expr(31: E::C(0, 0, 0, 0)) of type E has size 20 instead of 24
note: the compiler unexpectedly panicked. this is a bug.

@kmcallister kmcallister added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 16, 2015
@dotdash
Copy link
Contributor

dotdash commented Mar 4, 2015

Both examples compile fine with rustc 1.0.0-nightly (fed12499e 2015-03-03) (built 2015-03-04)

@dotdash dotdash closed this as completed Mar 4, 2015
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

No branches or pull requests

4 participants