-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Remove tests that were also added in PR 79684."
This reverts commit e118a2c.
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// error-pattern: any use of this value will cause an error | ||
|
||
#![feature(const_ptr_read)] | ||
#![feature(const_ptr_offset)] | ||
|
||
fn main() { | ||
use std::ptr; | ||
|
||
const DATA: [u32; 1] = [42]; | ||
|
||
const PAST_END_PTR: *const u32 = unsafe { DATA.as_ptr().add(1) }; | ||
|
||
const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; | ||
const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; | ||
const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
error: any use of this value will cause an error | ||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | ||
| | ||
LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| memory access failed: pointer must be in-bounds at offset 8, but is outside bounds of alloc6 which has size 4 | ||
| inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL | ||
| inside `_READ` at $DIR/out_of_bounds_read.rs:13:33 | ||
| | ||
::: $DIR/out_of_bounds_read.rs:13:5 | ||
| | ||
LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; | ||
| ------------------------------------------------------ | ||
| | ||
= note: `#[deny(const_err)]` on by default | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> | ||
|
||
error: any use of this value will cause an error | ||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | ||
| | ||
LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| memory access failed: pointer must be in-bounds at offset 8, but is outside bounds of alloc6 which has size 4 | ||
| inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL | ||
| inside `ptr::const_ptr::<impl *const u32>::read` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | ||
| inside `_CONST_READ` at $DIR/out_of_bounds_read.rs:14:39 | ||
| | ||
::: $DIR/out_of_bounds_read.rs:14:5 | ||
| | ||
LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; | ||
| -------------------------------------------------------- | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> | ||
|
||
error: any use of this value will cause an error | ||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | ||
| | ||
LL | copy_nonoverlapping(src, tmp.as_mut_ptr(), 1); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| memory access failed: pointer must be in-bounds at offset 8, but is outside bounds of alloc6 which has size 4 | ||
| inside `std::ptr::read::<u32>` at $SRC_DIR/core/src/ptr/mod.rs:LL:COL | ||
| inside `ptr::mut_ptr::<impl *mut u32>::read` at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL | ||
| inside `_MUT_READ` at $DIR/out_of_bounds_read.rs:15:37 | ||
| | ||
::: $DIR/out_of_bounds_read.rs:15:5 | ||
| | ||
LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; | ||
| -------------------------------------------------------------------- | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> | ||
|
||
error: aborting due to 3 previous errors | ||
|