-
Notifications
You must be signed in to change notification settings - Fork 393
Closed
Labels
A-intptrcastArea: affects int2ptr and ptr2int castsArea: affects int2ptr and ptr2int castsC-supportCategory: Not necessarily a bug, but someone asking for supportCategory: Not necessarily a bug, but someone asking for support
Description
The following safe code fails to run in Miri:
println!("{:?}", Box::into_raw(Box::new(4)));
error[E0080]: Miri evaluation error: a raw memory access tried to access part of a pointer value as raw bytes
--> /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/ops/arith.rs:528:45
|
528 | fn rem(self, other: $t) -> $t { self % other }
| ^^^^^^^^^^^^ Miri evaluation error: a raw memory access tried to access part of a pointer value as raw bytes
|
= note: inside call to `<usize as std::ops::Rem>::rem` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/fmt/num.rs:61:25
= note: inside call to `<core::fmt::num::LowerHex as core::fmt::num::GenericRadix>::fmt_int::<usize>` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/fmt/num.rs:135:46
= note: inside call to `core::fmt::num::<impl std::fmt::LowerHex for usize>::fmt` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/fmt/mod.rs:2024:19
= note: inside call to `<*const i32 as std::fmt::Pointer>::fmt` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/fmt/mod.rs:2036:9
= note: inside call to `<*mut i32 as std::fmt::Pointer>::fmt` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/fmt/mod.rs:2062:54
= note: inside call to `<*mut i32 as std::fmt::Debug>::fmt` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/fmt/mod.rs:1016:17
= note: inside call to `std::fmt::write` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/io/mod.rs:1288:15
= note: inside call to `<tests::test::Sink as std::io::Write>::write_fmt` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/io/impls.rs:141:9
= note: inside call to `std::io::impls::<impl std::io::Write for std::boxed::Box<dyn std::io::Write + std::marker::Send>>::write_fmt` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/io/stdio.rs:783:24
= note: inside call to closure at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/thread/local.rs:257:16
= note: inside call to `std::thread::LocalKey::<std::cell::RefCell<std::option::Option<std::boxed::Box<dyn std::io::Write + std::marker::Send>>>>::try_with::<[closure@DefId(1:2736 ~ std[797b]::io[0]::stdio[0]::print_to[0]::{{closure}}[0]) 0:&std::fmt::Arguments, 1:&fn() -> std::io::Stdout], std::result::Result<(), std::io::Error>>` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/io/stdio.rs:780:18
= note: inside call to `std::io::stdio::print_to::<std::io::Stdout>` at /Users/jrmuizel/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/io/stdio.rs:802:5
note: inside call to `std::io::_print` at <::std::macros::println macros>:2:4
--> src/lib.rs:5:9
|
5 | println!("{:?}", Box::into_raw(Box::new(4)));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Metadata
Metadata
Assignees
Labels
A-intptrcastArea: affects int2ptr and ptr2int castsArea: affects int2ptr and ptr2int castsC-supportCategory: Not necessarily a bug, but someone asking for supportCategory: Not necessarily a bug, but someone asking for support