Skip to content

Should drop_in_place imply dereferencability? #373

Open
@JakobDegen

Description

@JakobDegen

The following code is currently DB as reported by Miri:

#[repr(transparent)]
struct LoudDrop(u8);

impl Drop for LoudDrop {
    fn drop(&mut self) {
        println!("{}", self.0);
    }
}

#[repr(C)]
struct PartiallyDrop(LoudDrop, u8);

pub fn main() {
    let mut x = LoudDrop(0);
    let p = std::ptr::addr_of_mut!(x).cast::<PartiallyDrop>();
    
    unsafe {
        core::ptr::drop_in_place(p);   
    }
}

Should it be?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-open-questionCategory: An open question that we should revisit

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions