Skip to content

Commit 31532c9

Browse files
authored
Merge pull request #4 from stogaru/verify/ptr_const_slice_type
Verify/ptr const slice type
2 parents 8e49dcd + 9af0e39 commit 31532c9

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

library/core/src/ptr/const_ptr.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,6 +1796,40 @@ impl<T: ?Sized> PartialOrd for *const T {
17961796
mod verify {
17971797
use crate::kani;
17981798

1799+
#[allow(unused)]
1800+
1801+
#[kani::proof_for_contract(<*const i32>::offset)]
1802+
fn check_offset_slice_i32(){
1803+
let mut arr: [i32; 5] = kani::any();
1804+
let test_ptr: *const i32 = arr.as_ptr();
1805+
let offset: isize = kani::any();
1806+
1807+
unsafe{
1808+
let new_ptr = test_ptr.offset(offset);
1809+
}
1810+
}
1811+
1812+
#[kani::proof_for_contract(<*const i32>::add)]
1813+
fn check_add_slice_i32() {
1814+
let mut arr: [i32; 5] = kani::any();
1815+
let test_ptr: *const i32 = arr.as_ptr();
1816+
let count: usize = kani::any();
1817+
unsafe {
1818+
let new_ptr = test_ptr.add(count);
1819+
}
1820+
}
1821+
1822+
1823+
#[kani::proof_for_contract(<*const i32>::sub)]
1824+
fn check_sub_slice_i32() {
1825+
let mut arr: [i32; 5] = kani::any();
1826+
let test_ptr: *const i32 = arr.as_ptr();
1827+
let count: usize = kani::any();
1828+
unsafe {
1829+
let new_ptr = test_ptr.sub(count);
1830+
}
1831+
}
1832+
17991833
// fn <*const T>::add verification begin
18001834
macro_rules! generate_add_harness {
18011835
($type:ty, $proof_name:ident) => {

0 commit comments

Comments
 (0)