Skip to content

ICE: defining static with struct that contains enum with &'static str variant #13214

Closed
@arjantop

Description

@arjantop

If you change char in Test to int the error is gone, also adding another field or switching field positions in Test has the same effect.

Example:

pub enum Foo {
    Bar,
    Baz(&'static str),
}

pub static TEST: Test = Test {
    foo: Bar,
    c: 'a'
};

pub struct Test {
    foo: Foo,
    c: char,
}

fn main() {
}

Error:

{ { i8, [23 x i8] }, i32 } { { i8, [23 x i8] } { i8 0, [23 x i8] undef }, i32 97 }
{ { i8, [7 x i8], [2 x i64] }, i32 } undef
error: internal compiler error: const expr(17: Test{foo: Bar, c: 'a',}) of type Test has size 28 instead of 32
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace

Backtrace:

stack backtrace:
   1:     0x7f5a16de0230 - rt::backtrace::imp::write::h76ae436ab8cd2bfapZb::v0.10.pre
   2:     0x7f5a16d41a10 - rt::unwind::begin_unwind_inner::hf4375e02d9645bfaSzb::v0.10.pre
   3:     0x7f5a159ae830 - rt::unwind::begin_unwind::h3c590aa38e8709d1ok2::v0.10.pre
   4:     0x7f5a159af410 - diagnostic::Handler::bug::hf68c63085e9b6510YVb::v0.10.pre
   5:     0x7f5a177998e0 - driver::session::Session::bug::hfd0e2310310f12b7cih::v0.10.pre
   6:     0x7f5a1783bd80 - middle::trans::consts::const_expr::h43dc45f3937eaf8bFZi::v0.10.pre
   7:     0x7f5a177968c0 - middle::trans::base::get_item_val::h1e82e744da42398aqep::v0.10.pre
   8:     0x7f5a1783db50 - middle::trans::consts::trans_const::hf108c8e66bb317e7rNj::v0.10.pre
   9:     0x7f5a177956b0 - middle::trans::base::trans_item::h14eeb46ce9c8fca6uUo::v0.10.pre
  10:     0x7f5a178701d0 - middle::trans::base::trans_mod::hd916ddc9839c24eazZo::v0.10.pre
  11:     0x7f5a17879a20 - middle::trans::base::trans_crate::h4986f3f48477ce7b2vq::v0.10.pre
  12:     0x7f5a17f8db00 - driver::driver::phase_4_translate_to_llvm::had71317fbd14c5f8eHf::v0.10.pre
  13:     0x7f5a17f8fcd0 - driver::driver::compile_input::h396d5b0fd5bd11243Wf::v0.10.pre
  14:     0x7f5a17fb43f0 - run_compiler::h586972086a406218xAn::v0.10.pre
  15:     0x7f5a17fcb940 - main_args::closure.92068
  16:     0x7f5a17fca270 - monitor::closure.91953
  17:     0x7f5a17fc5ba0 - task::TaskBuilder::try::closure.91728
  18:     0x7f5a19d3c400 - task::spawn_opts::closure.7828
  19:     0x7f5a16ddb6c0 - rt::task::Task::run::closure.41627
  20:     0x7f5a16de6cd0 - rust_try
  21:     0x7f5a16ddb500 - rt::task::Task::run::hc847d6a2bcfd72f1os9::v0.10.pre
  22:     0x7f5a19d3c1d0 - task::spawn_opts::closure.7801
  23:     0x7f5a16dded70 - rt::thread::thread_start::he494c19e89c9f3eb569::v0.10.pre
  24:     0x7f5a140fafe0 - start_thread
  25:     0x7f5a16a0cce9 - clone
  26:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions