Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c33fc24

Browse files
committed
rustup
1 parent 8fdb720 commit c33fc24

File tree

5 files changed

+11
-23
lines changed

5 files changed

+11
-23
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
41419e70366962c9a878bfe673ef4df38db6f7f1
1+
35a061724802377a21fc6dac1ebcbb9b8d1f558a
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Some optimizations remove ZST accesses, thus masking this UB.
22
//@compile-flags: -Zmir-opt-level=0
3-
//@error-pattern: memory access failed: null pointer is a dangling pointer
43

54
#[allow(deref_nullptr)]
65
fn main() {
76
// Not using the () type here, as writes of that type do not even have MIR generated.
87
// Also not assigning directly as that's array initialization, not assignment.
98
let zst_val = [1u8; 0];
109
unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) };
10+
//~^ERROR: memory access failed: null pointer is a dangling pointer
1111
}

tests/fail/dangling_pointers/null_pointer_write_zst.stderr

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
error: Undefined Behavior: memory access failed: null pointer is a dangling pointer (it has no provenance)
2-
--> RUSTLIB/core/src/ptr/mod.rs:LL:CC
2+
--> $DIR/null_pointer_write_zst.rs:LL:CC
33
|
4-
LL | copy_nonoverlapping(&src as *const T, dst, 1);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance)
4+
LL | unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) };
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance)
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
99
= note: backtrace:
10-
= note: inside `std::ptr::write::<[u8; 0]>` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
11-
= note: inside `std::ptr::mut_ptr::<impl *mut [u8; 0]>::write` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
12-
note: inside `main` at $DIR/null_pointer_write_zst.rs:LL:CC
13-
--> $DIR/null_pointer_write_zst.rs:LL:CC
14-
|
15-
LL | unsafe { std::ptr::null_mut::<[u8; 0]>().write(zst_val) };
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
= note: inside `main` at $DIR/null_pointer_write_zst.rs:LL:CC
1711

1812
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1913

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
//@error-pattern: overflow computing total size of `write_bytes`
21
use std::mem;
32

43
fn main() {
54
let mut y = 0;
65
unsafe {
76
(&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::<usize>() * 8 - 1));
7+
//~^ ERROR: overflow computing total size of `write_bytes`
88
}
99
}

tests/fail/intrinsics/write_bytes_overflow.stderr

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
error: Undefined Behavior: overflow computing total size of `write_bytes`
2-
--> RUSTLIB/core/src/intrinsics.rs:LL:CC
2+
--> $DIR/write_bytes_overflow.rs:LL:CC
33
|
4-
LL | write_bytes(dst, val, count)
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `write_bytes`
4+
LL | (&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::<usize>() * 8 - 1));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `write_bytes`
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
99
= note: backtrace:
10-
= note: inside `std::intrinsics::write_bytes::<i32>` at RUSTLIB/core/src/intrinsics.rs:LL:CC
11-
= note: inside `std::ptr::mut_ptr::<impl *mut i32>::write_bytes` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
12-
note: inside `main` at $DIR/write_bytes_overflow.rs:LL:CC
13-
--> $DIR/write_bytes_overflow.rs:LL:CC
14-
|
15-
LL | (&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::<usize>() * 8 - 1));
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
= note: inside `main` at $DIR/write_bytes_overflow.rs:LL:CC
1711

1812
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1913

0 commit comments

Comments
 (0)