Skip to content

casting enum to itself results in an ICE #26426

Closed
@whitequark

Description

@whitequark

Excerpt:

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[repr(i32)]
pub enum Flicker {
    AC_60Hz         = 0,
    AC_50Hz         = 1,
    DC              = 2,
}
extern {
    fn Toupcam_get_HZ(h: *mut Handle, nHZ: *mut Flicker) -> HRESULT;
}
struct Handle;
struct Toupcam { handle: *mut Handle };
impl Toupcam {
    pub fn flicker_compensation(self: &mut Toupcam) -> Flicker {
        unsafe {
            let mut hz: Flicker = std::mem::zeroed();
            accept(Toupcam_get_HZ(self.handle, &mut hz));
            hz as Flicker
            // hz ← this works
        }
    }
}

rustc:

rustc 1.1.0-nightly (c033d9828 2015-05-09) (built 2015-05-09)

Backtrace:

thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:230

stack backtrace:
   1:     0x7f95e0cee149 - sys::backtrace::write::hf630cda5c057d925shs
   2:     0x7f95e0cf60c9 - panicking::on_panic::h3cbeeb6d9cf9a057vXw
   3:     0x7f95e0cb62a2 - rt::unwind::begin_unwind_inner::ha89a41e3e4923fa0FCw
   4:     0x7f95de093c6d - rt::unwind::begin_unwind::h7315671891021698504
   5:     0x7f95de09432b - diagnostic::Handler::bug::h1cc046814848dce7f8B
   6:     0x7f95dec8e60b - session::Session::bug::hfdd24549514c30bfUOq
   7:     0x7f95dfb8bf4b - trans::expr::trans_imm_cast::hf676a2bafa8a3d58OpC
   8:     0x7f95dfb80807 - trans::expr::trans_unadjusted::haa8fe9f5b3216facvCA
   9:     0x7f95dfb553ed - trans::expr::trans_into::h5aace87d45cda18fl9z
  10:     0x7f95dfad92e6 - trans::controlflow::trans_block::h83622bcb20d2285cw3u
  11:     0x7f95dfb8179b - trans::expr::trans_rvalue_dps_unadjusted::h3e4f1c626cf22366Y7A
  12:     0x7f95dfb553cc - trans::expr::trans_into::h5aace87d45cda18fl9z
  13:     0x7f95dfad92e6 - trans::controlflow::trans_block::h83622bcb20d2285cw3u
  14:     0x7f95dfad7bb6 - trans::base::trans_closure::h1623429c4a8ffbebjHh
  15:     0x7f95dfad98da - trans::base::trans_fn::hc7a5cef88d3731c91Rh
  16:     0x7f95dfadd6b2 - trans::base::trans_item::h1a43519c5bd06690dgi
  17:     0x7f95dfaead07 - trans::base::trans_crate::hadadeed95ebf196004i
  18:     0x7f95e1245d6a - driver::phase_4_translate_to_llvm::h7a1973fec1c0688cnOa
  19:     0x7f95e121e136 - driver::compile_input::h020e6002d10336a4Qba
  20:     0x7f95e12d7d61 - run_compiler::he8fc8a587311be2465b
  21:     0x7f95e12d55b2 - boxed::F.FnBox<A>::call_box::h13553308903082253150
  22:     0x7f95e12d4b79 - rt::unwind::try::try_fn::h3807368746205497482
  23:     0x7f95e0d69068 - rust_try_inner
  24:     0x7f95e0d69055 - rust_try
  25:     0x7f95e12d4e14 - boxed::F.FnBox<A>::call_box::h15011448770904444204
  26:     0x7f95e0cf4e61 - sys::thread::Thread::new::thread_start::h8bc03e8ed99cab4d1Iv
  27:     0x7f95dad8f0a3 - start_thread
  28:     0x7f95e094104c - clone
  29:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions