forked from model-checking/kani
-
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.
Address comments and use integer addition in offset
I decided to add a new test, and I bumped into issue model-checking#1150. Thus, I updated our model to use integer arithmetic operations instead of CBMC pointer arithmetic.
- Loading branch information
Showing
9 changed files
with
90 additions
and
38 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
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
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 @@ | ||
SUMMARY:\ | ||
** 5 of | ||
Failed Checks: Offset in bytes overflows isize | ||
Failed Checks: Offset result and original pointer must point to the same allocation | ||
Failed Checks: Offset value overflows isize | ||
Failed Checks: "This should fail for delta `1`" | ||
Failed Checks: "This should fail for delta `0`" | ||
|
||
Verification failed for - check_intrinsic_args | ||
Complete - 0 successfully verified harnesses, 1 failures, 1 total. |
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,18 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
//! Check different violations that can be triggered when providing an usize offset | ||
//! with a type that has size > 1. | ||
#![feature(core_intrinsics)] | ||
use std::intrinsics::offset; | ||
use std::ptr::addr_of; | ||
|
||
#[kani::proof] | ||
fn check_intrinsic_args() { | ||
let array = [0u32]; | ||
let delta: usize = kani::any(); | ||
let new = unsafe { offset(addr_of!(array), delta) }; | ||
assert!(delta <= 1, "Expected 0 and 1 to be the only safe values for offset"); | ||
assert_eq!(new, &array, "This should fail for delta `1`"); | ||
assert_ne!(new, &array, "This should fail for delta `0`"); | ||
} |
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 @@ | ||
Cannot offset by non-isize type u32 |
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 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
//! Check Kani output if the arguments provided to the offset intrinsic are incorrect. | ||
#![feature(core_intrinsics)] | ||
use std::intrinsics::offset; | ||
use std::ptr::addr_of; | ||
|
||
/// The rust compiler currently ICE. | ||
#[kani::proof] | ||
fn check_intrinsic_args() { | ||
let array = [0]; | ||
let delta: u32 = kani::any(); | ||
let new = unsafe { offset(addr_of!(array), delta) }; | ||
assert_ne!(new, &array) | ||
} |
File renamed without changes.
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