Skip to content

Commit 4aa1267

Browse files
committed
Update and bless tests for const read out of bounds
1 parent c012553 commit 4aa1267

File tree

2 files changed

+36
-28
lines changed

2 files changed

+36
-28
lines changed

src/test/ui/const-ptr/out_of_bounds_read.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern: any use of this value will cause an error
1+
// error-pattern: evaluation of constant value failed
22

33
#![feature(const_ptr_read)]
44
#![feature(const_ptr_offset)]
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,70 @@
1-
error: any use of this value will cause an error
1+
error[E0080]: evaluation of constant value failed
22
--> $SRC_DIR/core/src/intrinsics.rs:LL:COL
33
|
44
LL | unsafe { copy_nonoverlapping(src, dst, count) }
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
| |
77
| memory access failed: pointer must be in-bounds at offset 8, but is outside bounds of alloc6 which has size 4
88
| inside `copy_nonoverlapping::<u32>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL
9-
| inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
10-
| inside `_READ` at $DIR/out_of_bounds_read.rs:13:33
119
|
12-
::: $DIR/out_of_bounds_read.rs:13:5
10+
::: $SRC_DIR/core/src/ptr/mod.rs:LL:COL
1311
|
14-
LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
15-
| ------------------------------------------------------
12+
LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1);
13+
| --------------------------------------------- inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
14+
|
15+
::: $DIR/out_of_bounds_read.rs:13:33
1616
|
17-
= note: `#[deny(const_err)]` on by default
18-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
19-
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
17+
LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
18+
| ----------------------- inside `_READ` at $DIR/out_of_bounds_read.rs:13:33
2019

21-
error: any use of this value will cause an error
20+
error[E0080]: evaluation of constant value failed
2221
--> $SRC_DIR/core/src/intrinsics.rs:LL:COL
2322
|
2423
LL | unsafe { copy_nonoverlapping(src, dst, count) }
2524
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2625
| |
2726
| memory access failed: pointer must be in-bounds at offset 8, but is outside bounds of alloc6 which has size 4
2827
| inside `copy_nonoverlapping::<u32>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL
29-
| inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
30-
| inside `ptr::const_ptr::<impl *const u32>::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
31-
| inside `_CONST_READ` at $DIR/out_of_bounds_read.rs:14:39
3228
|
33-
::: $DIR/out_of_bounds_read.rs:14:5
29+
::: $SRC_DIR/core/src/ptr/mod.rs:LL:COL
3430
|
35-
LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
36-
| --------------------------------------------------------
31+
LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1);
32+
| --------------------------------------------- inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
33+
|
34+
::: $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
35+
|
36+
LL | unsafe { read(self) }
37+
| ---------- inside `ptr::const_ptr::<impl *const u32>::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
38+
|
39+
::: $DIR/out_of_bounds_read.rs:14:39
3740
|
38-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
39-
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
41+
LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
42+
| ------------------- inside `_CONST_READ` at $DIR/out_of_bounds_read.rs:14:39
4043

41-
error: any use of this value will cause an error
44+
error[E0080]: evaluation of constant value failed
4245
--> $SRC_DIR/core/src/intrinsics.rs:LL:COL
4346
|
4447
LL | unsafe { copy_nonoverlapping(src, dst, count) }
4548
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4649
| |
4750
| memory access failed: pointer must be in-bounds at offset 8, but is outside bounds of alloc6 which has size 4
4851
| inside `copy_nonoverlapping::<u32>` at $SRC_DIR/core/src/intrinsics.rs:LL:COL
49-
| inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
50-
| inside `ptr::mut_ptr::<impl *mut u32>::read` at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
51-
| inside `_MUT_READ` at $DIR/out_of_bounds_read.rs:15:37
5252
|
53-
::: $DIR/out_of_bounds_read.rs:15:5
53+
::: $SRC_DIR/core/src/ptr/mod.rs:LL:COL
5454
|
55-
LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
56-
| --------------------------------------------------------------------
55+
LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1);
56+
| --------------------------------------------- inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
57+
|
58+
::: $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
5759
|
58-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
59-
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
60+
LL | unsafe { read(self) }
61+
| ---------- inside `ptr::mut_ptr::<impl *mut u32>::read` at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
62+
|
63+
::: $DIR/out_of_bounds_read.rs:15:37
64+
|
65+
LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
66+
| --------------------------------- inside `_MUT_READ` at $DIR/out_of_bounds_read.rs:15:37
6067

6168
error: aborting due to 3 previous errors
6269

70+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)