-
Notifications
You must be signed in to change notification settings - Fork 350
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 #1031 - RalfJung:ptr-offset, r=RalfJung
Refactor ptr_offset_inbounds I finally found a way to write this using basically just `check_ptr_access` while handling all cases (integers and pointers, offset 0 or not) correctly. This changes behavior for NULL ptrs, but I think the change is for the better. Depends on rust-lang/rust#66081.
- Loading branch information
Showing
3 changed files
with
23 additions
and
37 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 |
---|---|---|
@@ -1 +1 @@ | ||
3a1b3b30c6cdd674049b144a3ced7b711de962b2 | ||
e4931eaaa3d95189b30e90d3af9f0db17c41bbb0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// error-pattern: invalid use of NULL pointer | ||
|
||
fn main() { | ||
let x = 0 as *mut i32; | ||
let _x = x.wrapping_offset(8); // ok, this has no inbounds tag | ||
let _x = unsafe { x.offset(0) }; // UB despite offset 0, NULL is never inbounds | ||
} |