Skip to content

Does this code violate the alias model? #3921

Closed
@Luv-Ray

Description

@Luv-Ray

come here from rust-lang/rust#130853
here is simplified code, which can be successfully run by miri

fn main() {
    let mut s = 0u8;
    let borrow = &raw mut s;
    unsafe {
        let const_borrow: *const *mut u8 = &raw const borrow;
        let x: &&u8 = &*const_borrow.cast::<&u8>();

        let y1 = **x; // get the value from `&&u8`
        *borrow = 1; // modify `s`
        let y2 = **x; // and the value changed
        assert!(y1 != y2);
    }
}

Does this code conform to the alias model? Or miri has some issues with handling cast?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions