rustup
This commit is contained in:
parent
8fdb720329
commit
c33fc24566
@ -1 +1 @@
|
|||||||
41419e70366962c9a878bfe673ef4df38db6f7f1
|
35a061724802377a21fc6dac1ebcbb9b8d1f558a
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Some optimizations remove ZST accesses, thus masking this UB.
|
// Some optimizations remove ZST accesses, thus masking this UB.
|
||||||
//@compile-flags: -Zmir-opt-level=0
|
//@compile-flags: -Zmir-opt-level=0
|
||||||
//@error-pattern: memory access failed: null pointer is a dangling pointer
|
|
||||||
|
|
||||||
#[allow(deref_nullptr)]
|
#[allow(deref_nullptr)]
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -8,4 +7,5 @@ fn main() {
|
|||||||
// Also not assigning directly as that's array initialization, not assignment.
|
// Also not assigning directly as that's array initialization, not assignment.
|
||||||
let zst_val = [1u8; 0];
|
let zst_val = [1u8; 0];
|
||||||
unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) };
|
unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) };
|
||||||
|
//~^ERROR: memory access failed: null pointer is a dangling pointer
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
error: Undefined Behavior: memory access failed: null pointer is a dangling pointer (it has no provenance)
|
error: Undefined Behavior: memory access failed: null pointer is a dangling pointer (it has no provenance)
|
||||||
--> RUSTLIB/core/src/ptr/mod.rs:LL:CC
|
--> $DIR/null_pointer_write_zst.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | copy_nonoverlapping(&src as *const T, dst, 1);
|
LL | unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance)
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance)
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
||||||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
= note: backtrace:
|
= note: backtrace:
|
||||||
= note: inside `std::ptr::write::<[u8; 0]>` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
|
= note: inside `main` at $DIR/null_pointer_write_zst.rs:LL:CC
|
||||||
= note: inside `std::ptr::mut_ptr::<impl *mut [u8; 0]>::write` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
|
|
||||||
note: inside `main` at $DIR/null_pointer_write_zst.rs:LL:CC
|
|
||||||
--> $DIR/null_pointer_write_zst.rs:LL:CC
|
|
||||||
|
|
|
||||||
LL | unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) };
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
//@error-pattern: overflow computing total size of `write_bytes`
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut y = 0;
|
let mut y = 0;
|
||||||
unsafe {
|
unsafe {
|
||||||
(&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::<usize>() * 8 - 1));
|
(&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::<usize>() * 8 - 1));
|
||||||
|
//~^ ERROR: overflow computing total size of `write_bytes`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
error: Undefined Behavior: overflow computing total size of `write_bytes`
|
error: Undefined Behavior: overflow computing total size of `write_bytes`
|
||||||
--> RUSTLIB/core/src/intrinsics.rs:LL:CC
|
--> $DIR/write_bytes_overflow.rs:LL:CC
|
||||||
|
|
|
|
||||||
LL | write_bytes(dst, val, count)
|
LL | (&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::<usize>() * 8 - 1));
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `write_bytes`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `write_bytes`
|
||||||
|
|
|
|
||||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
||||||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||||
= note: backtrace:
|
= note: backtrace:
|
||||||
= note: inside `std::intrinsics::write_bytes::<i32>` at RUSTLIB/core/src/intrinsics.rs:LL:CC
|
= note: inside `main` at $DIR/write_bytes_overflow.rs:LL:CC
|
||||||
= note: inside `std::ptr::mut_ptr::<impl *mut i32>::write_bytes` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
|
|
||||||
note: inside `main` at $DIR/write_bytes_overflow.rs:LL:CC
|
|
||||||
--> $DIR/write_bytes_overflow.rs:LL:CC
|
|
||||||
|
|
|
||||||
LL | (&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::<usize>() * 8 - 1));
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user