Skip to content

ICE when using unsafe blocks + UnsafeCell + a move #21945

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
jroesch opened this issue Feb 4, 2015 · 1 comment
Closed

ICE when using unsafe blocks + UnsafeCell + a move #21945

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

Comments

@jroesch
Copy link
Member

jroesch commented Feb 4, 2015

This is just some experimentation on my part that triggered an ICE. I may have time to investigate later but for now here is the smallest chunk of code I have and a playground session.

use std::thunk::Thunk;
use std::cell::UnsafeCell;
use std::mem::transmute;

struct Lazy<T> {
    value: UnsafeCell<Option<T>>,
    thunk: UnsafeCell<Option<Thunk<(), T>>>,
}

impl<T> Lazy<T> {
    fn value(&self) -> &T {
        unsafe { 
            let value = self.value.get();
            // deleted some code here
            let raw_value = &(*value).unwrap();
            transmute(raw_value)
        }
    }
}

fn main() {
}

http://is.gd/L2RIMD

@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 4, 2015
@jdm
Copy link
Contributor

jdm commented Feb 4, 2015

Duplicate of #20801.

@jdm jdm closed this as completed Feb 4, 2015
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

2 participants