Skip to content

ICE: translating unsupported cast: *const str (cast_other) -> *const Slice<u8> (cast_pointer) #22554

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

Closed
JinShil opened this issue Feb 20, 2015 · 1 comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@JinShil
Copy link

JinShil commented Feb 20, 2015

Code to reproduce.

#[repr(C)]
#[allow(dead_code)]
struct Slice<T> {
    data: *const T,
    len: usize,
}

fn main() {
    let text = "Hello World!\n";
    let t1 = text as *const str;
    let t2 = t1 as *const Slice<u8>;
}

Rust Playpen: http://is.gd/jfBLrG

Output

error: internal compiler error: translating unsupported cast: *const str (cast_other) -> *const Slice<u8> (cast_pointer)
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
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:189
@kmcallister kmcallister added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 20, 2015
@tamird
Copy link
Contributor

tamird commented Apr 22, 2015

Triage: no longer ICEs.

$ rustc main.rs
main.rs:11:14: 11:36 error: illegal cast; cast from fat pointer: `*const str` as `*const Slice<u8>`
main.rs:11     let t2 = t1 as *const Slice<u8>;
                        ^~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

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