File tree Expand file tree Collapse file tree 5 files changed +27
-8
lines changed
shadow/unsupported_object_size Expand file tree Collapse file tree 5 files changed +27
-8
lines changed Original file line number Diff line number Diff line change @@ -287,14 +287,9 @@ macro_rules! kani_mem {
287
287
288
288
/// Get the object offset of the given pointer.
289
289
#[ doc( hidden) ]
290
- #[ crate :: kani:: unstable_feature(
291
- feature = "ghost-state" ,
292
- issue = 3184 ,
293
- reason = "experimental ghost state/shadow memory API"
294
- ) ]
295
290
#[ kanitool:: fn_marker = "PointerOffsetHook" ]
296
291
#[ inline( never) ]
297
- pub fn pointer_offset<T : PointeeSized >( _ptr: * const T ) -> usize {
292
+ pub ( crate ) fn pointer_offset<T : PointeeSized >( _ptr: * const T ) -> usize {
298
293
kani_intrinsic( )
299
294
}
300
295
} ;
Original file line number Diff line number Diff line change @@ -85,7 +85,9 @@ macro_rules! generate_models {
85
85
"Offset result and original pointer should point to the same allocation" ,
86
86
) ;
87
87
// The offset must fit in isize since this represents the same allocation.
88
- let offset_bytes = ptr1. addr( ) . wrapping_sub( ptr2. addr( ) ) as isize ;
88
+ let offset_bytes = kani:: mem:: pointer_offset( ptr1)
89
+ . wrapping_sub( kani:: mem:: pointer_offset( ptr2) )
90
+ as isize ;
89
91
let t_size = size_of:: <T >( ) as isize ;
90
92
kani:: safety_check(
91
93
offset_bytes % t_size == 0 ,
Original file line number Diff line number Diff line change 5
5
// This test checks the maximum object size supported by Kani's shadow
6
6
// memory model (currently 64)
7
7
8
+ #![ feature( core_intrinsics) ]
9
+ use std:: intrinsics:: ptr_offset_from_unsigned;
10
+
8
11
static mut SM : kani:: shadow:: ShadowMem < bool > = kani:: shadow:: ShadowMem :: new ( false ) ;
9
12
10
13
fn check_max_objects < const N : usize > ( ) {
11
14
let arr: [ u8 ; N ] = [ 0 ; N ] ;
12
15
let last = & arr[ N - 1 ] ;
13
- assert_eq ! ( kani:: mem:: pointer_offset( last as * const u8 ) , N - 1 ) ;
16
+ unsafe {
17
+ assert_eq ! ( ptr_offset_from_unsigned( last as * const u8 , & arr[ 0 ] as * const u8 ) , N - 1 ) ;
18
+ }
14
19
// the following call to `set_init` would fail if the object offset for
15
20
// `last` exceeds the maximum allowed by Kani's shadow memory model
16
21
unsafe {
Original file line number Diff line number Diff line change
1
+ Failed Checks: called `Option::unwrap()` on a `None` value
2
+ Verification failed for - repeat_panic
3
+ Complete - 1 successfully verified harnesses, 1 failures, 2 total.
Original file line number Diff line number Diff line change
1
+ // Copyright Kani Contributors
2
+ // SPDX-License-Identifier: Apache-2.0 OR MIT
3
+
4
+ #[ kani:: proof]
5
+ fn repeat_const ( ) {
6
+ let s = String :: from ( "a" ) . repeat ( 1 ) ;
7
+ assert_eq ! ( s. chars( ) . nth( 0 ) . unwrap( ) , 'a' ) ;
8
+ }
9
+
10
+ #[ kani:: proof]
11
+ fn repeat_panic ( ) {
12
+ let x = String :: new ( ) . repeat ( 1 ) ;
13
+ let z = x. chars ( ) . nth ( 1 ) . unwrap ( ) ;
14
+ }
You can’t perform that action at this time.
0 commit comments