Closed
Description
Hi I tried to check if circular reference counted pointer are somehow freed in rust, because it is sometimes possible to accidentally create such constructs. Sadly it doesn't seem to be the case.
Here is the code I used to test this (rust playpen): http://is.gd/I40LCd
#![feature(unsafe_destructor)]
use std::rc::Rc;
use std::cell::RefCell;
struct Object {
sub: RefCell<Option<Rc<Object>>>
}
#[unsafe_destructor]
impl Drop for Object {
fn drop(&mut self) {
println!("Dropped");
}
}
fn main() {
let obj = Rc::new(Object { sub: RefCell::new(None) });
(*obj.sub.borrow_mut()) = Some(obj.clone());
println!("Hello, world!")
}
I am sorry if this is a duplicate or if I did test it wrong. I don't have access to valgrind right now.
Metadata
Metadata
Assignees
Labels
No labels