forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for pointer overflow checking (rust-lang#792)
- Loading branch information
Showing
2 changed files
with
24 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,10 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// kani-verify-fail | ||
|
||
pub fn main() { | ||
let a = [0; 5]; | ||
let i: i32 = 0; | ||
let ptr1: *const i32 = &a[0]; | ||
let ptr_overflow1 = unsafe { ptr1.offset(isize::MAX) }; | ||
} |
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,14 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// kani-verify-fail | ||
// This should fail, but doesn't due to https://github.com/diffblue/cbmc/issues/6631 | ||
|
||
pub fn main() { | ||
let a = [0; 5]; | ||
let i: i32 = 0; | ||
let ptr1: *const i32 = &a[1]; | ||
let ptr2: *const i32 = &i; | ||
let ptr2 = unsafe { ptr2.offset(1) }; | ||
let ptr_overflow1 = unsafe { ptr1.offset(isize::MAX) }; | ||
let ptr_overflow2 = unsafe { ptr2.offset(isize::MAX) }; | ||
} |