Skip to content

Miri checks ptr.read() but not dereferencing a pointer (*ptr) #1526

Closed
@elichai

Description

@elichai

Hi,
miri complains on this:

fn main() {
    unsafe {
        let a = [1u8,2,3];
        let b = &a[0] as *const u8;
        println!("{}", b.add(1).read());
    }
}

https://play.rust-lang.org/?gist=5af194a447ac5e0d38796c809e3a0e6f
but not on this:

fn main() {
    unsafe {
        let a = [1u8,2,3];
        let b = &a[0] as *const u8;
        println!("{}", *b.add(1));
    }
}

https://play.rust-lang.org/?gist=6b7d13c8b77d8e14e06d9133a19e992f

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-supportCategory: Not necessarily a bug, but someone asking for support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions