You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following program used to work, but now it fails:
use std::{
cell::UnsafeCell,
sync::atomic::{AtomicPtr,Ordering},};#[repr(C)]#[derive(Default)]structNode{_meta:UnsafeCell<usize>,value:usize,}implNode{fnvalue(&self) -> &usize{&self.value}}fnmain(){unsafe{let a = Box::into_raw(Box::new(Node::default()));let ptr = &*a;*UnsafeCell::raw_get(a.cast::<UnsafeCell<usize>>()) = 2;println!("{}", ptr.value());}}
That is caused by rust-lang/rust#122647. That PR even has a commenting about this situation -- code doing a box-to-raw cast while being generic over the allocator is just not something we can handle properly.
The text was updated successfully, but these errors were encountered:
Rollup merge of rust-lang#124013 - RalfJung:box-to-raw, r=oli-obk
Box::into_raw: make Miri understand that this is a box-to-raw cast
Turns out rust-lang#122647 went a bit too far in cleaning up `Box`... we still need a hack in `Box::into_raw`. The nicer fix would be to make Stacked Borrows not care about reference-to-raw-pointer casts, but it's unclear whether that will ever be possible without going to full Tree Borrows.
Fixesrust-lang/miri#3473.
Box::into_raw: make Miri understand that this is a box-to-raw cast
Turns out rust-lang/rust#122647 went a bit too far in cleaning up `Box`... we still need a hack in `Box::into_raw`. The nicer fix would be to make Stacked Borrows not care about reference-to-raw-pointer casts, but it's unclear whether that will ever be possible without going to full Tree Borrows.
Fixes#3473.
The following program used to work, but now it fails:
That is caused by rust-lang/rust#122647. That PR even has a commenting about this situation -- code doing a box-to-raw cast while being generic over the allocator is just not something we can handle properly.
The text was updated successfully, but these errors were encountered: