Skip to content

error: internal compiler error: translating unsupported cast: libc::types::common::c95::c_void (cast_enum) -> *mut f32 (cast_pointer) #17444

Closed
@nicklan

Description

@nicklan

The following program causes rustc to crash:

extern crate libc;
use std::c_vec::CVec;


fn void_buf() -> libc::c_void {
    unsafe {
        std::mem::transmute(b'0')
    }
}

fn main() {
    unsafe{
        CVec::new(void_buf() as *mut f32,0);
    }
}

Obviously it's badly typed (converting void to a pointer type), but the compiler shouldn't crash here right? :)

output of rustc -v: rustc 0.12.0-pre-nightly (09abbbd 2014-09-11 00:05:41 +0000)

backtrace from trying to compile;

error: internal compiler error: translating unsupported cast: libc::types::common::c95::c_void (cast_enum) -> *mut f32 (cast_pointer)
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 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/ast_util.rs:776

stack backtrace:
   1:     0x7f30f3711880 - rt::backtrace::imp::write::h6280ef424d93578eYFq
   2:     0x7f30f3714a80 - failure::on_fail::hd9f0344ab848748bq1q
   3:     0x7f30f7c7bdf0 - unwind::begin_unwind_inner::h1fb7b215753db772MTd
   4:     0x7f30f6223120 - unwind::begin_unwind::h1902930648154155005
   5:     0x7f30f62238c0 - diagnostic::Handler::bug::h5fa2fdf0a394a866YID
   6:     0x7f30f82d7dd0 - driver::session::Session::bug::h31584d237f0b1c7aHnv
   7:     0x7f30f8725570 - middle::trans::expr::trans_imm_cast::hfcbb834eeb12c5d6QZ2
   8:     0x7f30f8718590 - middle::trans::expr::trans_unadjusted::h0ddf38fb0dd9ac54Q60
   9:     0x7f30f86d7550 - middle::trans::expr::trans::hf17957ab9b3c28232o0
  10:     0x7f30f87114b0 - middle::trans::callee::trans_args::h0af8fd993cc8dfechUZ
  11:     0x7f30f86df600 - middle::trans::callee::trans_call_inner::hb705da9b2ec56867izZ
  12:     0x7f30f870b070 - middle::trans::callee::trans_call::h82b56b8467ae33aeBtZ
  13:     0x7f30f8719640 - middle::trans::expr::trans_rvalue_dps_unadjusted::hd2382dd726436e17OG1
  14:     0x7f30f8718590 - middle::trans::expr::trans_unadjusted::h0ddf38fb0dd9ac54Q60
  15:     0x7f30f86d7550 - middle::trans::expr::trans::hf17957ab9b3c28232o0
  16:     0x7f30f86d52e0 - middle::trans::controlflow::trans_stmt_semi::h5d141746b25726bbinW
  17:     0x7f30f86d4970 - middle::trans::controlflow::trans_stmt::h6a70859a372a5e27fjW
  18:     0x7f30f86d6340 - middle::trans::controlflow::trans_block::h2335b3c4eec688f0boW
  19:     0x7f30f8719640 - middle::trans::expr::trans_rvalue_dps_unadjusted::hd2382dd726436e17OG1
  20:     0x7f30f86d5ea0 - middle::trans::expr::trans_into::h9d43d42a11539cf0il0
  21:     0x7f30f86d6340 - middle::trans::controlflow::trans_block::h2335b3c4eec688f0boW
  22:     0x7f30f8784fb0 - middle::trans::base::trans_closure::hf32195399c54cea9Tqc
  23:     0x7f30f86c6250 - middle::trans::base::trans_fn::h5d400738a2233bcc6Bc
  24:     0x7f30f86c1830 - middle::trans::base::trans_item::h2b7563fbd8aacff6fVc
  25:     0x7f30f8791930 - middle::trans::base::trans_crate::hd8f395f79f2d91279Sd
  26:     0x7f30f8be70d0 - driver::driver::phase_4_translate_to_llvm::hc53882c1ebc8022a8Ou
  27:     0x7f30f8bde3b0 - driver::driver::compile_input::h0ec09ff4cede62cdxqu
  28:     0x7f30f8c73020 - driver::run_compiler::h90a2945ca74d50e07ay
  29:     0x7f30f8c72f10 - driver::main_args::closure.148408
  30:     0x7f30f8306ac0 - task::TaskBuilder<S>::try_future::closure.100323
  31:     0x7f30f83068b0 - task::TaskBuilder<S>::spawn_internal::closure.100294
  32:     0x7f30f7fcfda0 - task::spawn_opts::closure.8416
  33:     0x7f30f7cd4380 - rust_try_inner
  34:     0x7f30f7cd4370 - rust_try
  35:     0x7f30f7c79380 - unwind::try::h69140ac3a4141faauId
  36:     0x7f30f7c791e0 - task::Task::run::h449c8493a0d61f09fYc
  37:     0x7f30f7fcfb10 - task::spawn_opts::closure.8356
  38:     0x7f30f7c7ae20 - thread::thread_start::h71dd1e21d4d03408rid
  39:     0x7f30f2ab3250 - start_thread
  40:     0x7f30f79543b9 - clone
  41:                0x0 - <unknown>

Let me know if you need more information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions