Skip to content

[Miri Error] use {:p} in println! statement #53350

@ZhangHanDong

Description

@ZhangHanDong
#![allow(unused)]
fn main() {
    let a = [1,2,3];
    println!("{:p}", &a);  // 0x7ffcbc067704
}

Play

execute this programme in Miri , got the following error:

error[E0080]: constant evaluation error: a raw memory access tried to access part of a pointer value as raw bytes
   --> /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/cmp.rs:869:52
    |
869 |                 fn ge(&self, other: &$t) -> bool { (*self) >= (*other) }
    |                                                    ^^^^^^^^^^^^^^^^^^^ a raw memory access tried to access part of a pointer value as raw bytes
    |
   ...
   ...

   4   |     println!("{:p}", &a);  // 0x7ffcbc067704
    |     ^^^^^^^^^^^^^^^^^^^^^
note: inside call to `main`
   ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions