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

Playground ICE while playing around with nasal demons #51706

Closed
flying-sheep opened this issue Jun 22, 2018 · 2 comments
Closed

Playground ICE while playing around with nasal demons #51706

flying-sheep opened this issue Jun 22, 2018 · 2 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@flying-sheep
Copy link

when encountering this comment i wanted to play around with it, resulting in this

reproduced here:

extern crate rand;

use std::intrinsics::transmute;

fn main() {
    unsafe { call_me_maybe(); }
}

unsafe fn call_me_maybe() -> ! {
    if rand::random() {
        transmute(())
    } else {
        loop {}
    }
}

And I get:

   Compiling playground v0.0.1 (file:///playground)
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:335:21
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error: internal compiler error: unexpected panic

[…]

note: rustc 1.27.0 (3eda71b00 2018-06-19) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin
@stokhos stokhos added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jun 22, 2018
@fanzier
Copy link
Contributor

fanzier commented Jun 22, 2018

The rand::random() doesn't seem to matter, this also crashes:

unsafe fn dont_call_me() -> ! { 
    std::mem::transmute(()) 
}

fn main() {
    unsafe { dont_call_me() }
}

Playground

@varkor
Copy link
Member

varkor commented Jun 23, 2018

This is fixed on Nightly (by #50803). It instead results in undefined behaviour, as expected.

@varkor varkor closed this as completed Jun 23, 2018
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