Skip to content

Miri errors when transmuting part of a pointer to an integer #2456

Closed
rust-lang/rust
#101101
@GoldsteinE

Description

@GoldsteinE

This program triggers Miri:

fn main() {
    let x: [u8; 8] = unsafe { std::mem::transmute(&0) };
    println!("{x:?}");
}

But these two don’t:

fn main() {
    let x: usize = unsafe { std::mem::transmute(&0) };
    println!("{x:?}");
}
fn main() {
    let x: [u8; 8] = unsafe { std::mem::transmute(std::mem::transmute::<_, usize>(&0)) };
    println!("{x:?}");
}

It looks like it should trigger in all of these snippets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-interpreterArea: affects the core interpreterC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions