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

Trying to cast a raw pointer to a trait pointer results in ICE #18998

Closed
ghost opened this issue Nov 16, 2014 · 3 comments
Closed

Trying to cast a raw pointer to a trait pointer results in ICE #18998

ghost opened this issue Nov 16, 2014 · 3 comments
Labels
A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@ghost
Copy link

ghost commented Nov 16, 2014

fn foo(bar: *const u8) {
    let a = unsafe { (bar as *const Writer) };
}

fn main() {
}
<anon>:3:23: 3:26 error: internal compiler error: expected object type
<anon>:3     let a = unsafe { (bar as *const Writer) };
                               ^~~
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>', /build/rust-git/src/rust/src/libsyntax/diagnostic.rs:116
@huonw huonw added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-DSTs Area: Dynamically-sized types (DSTs) labels Nov 16, 2014
@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

Still an issue:

$ cat main.rs
use std::io::Write;

fn foo(bar: *const u8) -> *const Write {
    bar as *const Write
}

fn main() {
  let _ = foo(&7);
}
$ RUST_BACKTRACE=1 rustc main.rs
error: internal compiler error: translating unsupported cast: *const u8 (cast_pointer) -> *const std::io::Write (cast_other)
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 'Box<Any>', /Users/tamird/src/rust/src/libsyntax/diagnostic.rs:230

stack backtrace:
   1:        0x10380853f - sys::backtrace::write::h8b9cc0e6b4558d6fnSs
   2:        0x103810ad2 - panicking::on_panic::hb84a54d9bdda0209CPw
   3:        0x1037c6cd5 - rt::unwind::begin_unwind_inner::h12cc96d4563962fclxw
   4:        0x102fce60e - rt::unwind::begin_unwind::h8554955808482497848
   5:        0x102fcedb2 - diagnostic::Handler::bug::hf9d658ba3ad60a681wB
   6:        0x100d57de7 - session::Session::bug::h996fc02cafac252bClp
   7:        0x10057116c - trans::expr::trans_imm_cast::hc380d2dff304ead8uoC
   8:        0x10056511e - trans::expr::trans_unadjusted::hda4f420c51313d0bbBA
   9:        0x1004991ef - trans::expr::trans::h9b4ecaab7176a08bieA
  10:        0x100539150 - trans::expr::trans_into::h054f76c51f01e5feZ7z
  11:        0x1004ba4b9 - trans::controlflow::trans_block::hcf83ff649913f4b923u
  12:        0x1004b8db6 - trans::base::trans_closure::hc90fb8352e6a23e9BDh
  13:        0x1004baaee - trans::base::trans_fn::h30ceafdd164c6b32jOh
  14:        0x1004be0e8 - trans::base::trans_item::hef31bbee38b11859vci
  15:        0x1004ccf30 - trans::base::trans_crate::ha0e1db7844d97546v1i
  16:        0x10032e2ae - driver::phase_4_translate_to_llvm::h62a23938e2c925f3nOa
  17:        0x100306579 - driver::compile_input::hb2bddda14f816e70Qba
  18:        0x1003cdd03 - run_compiler::h0b99cbf9200c123bF4b
  19:        0x1003cb82a - boxed::F.FnBox<A>::call_box::h12835505560322522005
  20:        0x1003cacc7 - rt::unwind::try::try_fn::h9284484278680574813
  21:        0x10389d028 - rust_try_inner
  22:        0x10389d015 - rust_try
  23:        0x1003cafa0 - boxed::F.FnBox<A>::call_box::h15674394682208383701
  24:        0x10380f63d - sys::thread::create::thread_start::hdaf0bf4a4fc759cbeVv
  25:     0x7fff8825a898 - _pthread_body
  26:     0x7fff8825a729 - _pthread_start

@pmarcelll
Copy link
Contributor

It seems to be fixed:

rustc 1.2.0-nightly (0250ff9a5 2015-06-17)

test.rs:4:5: 4:8 error: the trait `std::io::Write` is not implemented for the type `u8` [E0277]
test.rs:4     bar as *const Write
              ^~~
error: aborting due to previous error

@alexcrichton
Copy link
Member

Yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants