Skip to content

Playground ICE while playing around with nasal demons #51706

Closed

Description

@flying-sheep

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

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    on Jun 22, 2018
  2. fanzier commented on Jun 22, 2018

    @fanzier
    Contributor

    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

  3. varkor commented on Jun 23, 2018

    @varkor
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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