forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#2193 - RalfJung:strict, r=RalfJung
do not use int2ptr casts in strict provenance tests
- Loading branch information
Showing
3 changed files
with
10 additions
and
6 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
...il/provenance/strict-provenance-offset.rs → tests/fail/provenance/ptr_invalid_offset.rs
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
// compile-flags: -Zmiri-strict-provenance | ||
// error-pattern: not a valid pointer | ||
#![feature(strict_provenance)] | ||
|
||
fn main() { | ||
let x = 22; | ||
let ptr = &x as *const _ as *const u8; | ||
let roundtrip = ptr as usize as *const u8; | ||
let roundtrip = std::ptr::invalid::<u8>(ptr as usize); | ||
// Not even offsetting this is allowed. | ||
let _ = unsafe { roundtrip.offset(1) }; | ||
} |
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
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