Skip to content

Commit 6720d44

Browse files
danielsntedinski
authored andcommitted
Add tests for pointer overflow checking (rust-lang#792)
1 parent 6ce9a04 commit 6720d44

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
// kani-verify-fail
4+
5+
pub fn main() {
6+
let a = [0; 5];
7+
let i: i32 = 0;
8+
let ptr1: *const i32 = &a[0];
9+
let ptr_overflow1 = unsafe { ptr1.offset(isize::MAX) };
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
// kani-verify-fail
4+
// This should fail, but doesn't due to https://github.com/diffblue/cbmc/issues/6631
5+
6+
pub fn main() {
7+
let a = [0; 5];
8+
let i: i32 = 0;
9+
let ptr1: *const i32 = &a[1];
10+
let ptr2: *const i32 = &i;
11+
let ptr2 = unsafe { ptr2.offset(1) };
12+
let ptr_overflow1 = unsafe { ptr1.offset(isize::MAX) };
13+
let ptr_overflow2 = unsafe { ptr2.offset(isize::MAX) };
14+
}

0 commit comments

Comments
 (0)