File tree 7 files changed +19
-19
lines changed
cbmc-primitives/pointer-offset-01
contracts/no_redudant_checks
7 files changed +19
-19
lines changed Original file line number Diff line number Diff line change 3
3
--no-simplify --no-propagation
4
4
^EXIT=10$
5
5
^SIGNAL=0$
6
- \[main.assertion.1\] line \d+ assertion __CPROVER_POINTER_OFFSET\(p\) >= 0: FAILURE
6
+ \[main.assertion.1\] line \d+ assertion __CPROVER_POINTER_OFFSET\(p\) >= 0: SUCCESS
7
7
\[main.assertion.2\] line \d+ assertion __CPROVER_POINTER_OFFSET\(p\) < 0: FAILURE
8
8
--
9
9
^warning: ignoring
10
10
--
11
- Check that both positive and negative offsets can be chosen for uninitialized
12
- pointers. We use --no-simplify and --no-propagation to ensure that the case is
13
- not solved by the constant propagation and thus tests the constraint encoding.
11
+ Check that positive offsets can be chosen for uninitialized pointers. We
12
+ use --no-simplify and --no-propagation to ensure that the case is not solved
13
+ by the constant propagation and thus tests the constraint encoding.
Original file line number Diff line number Diff line change 3
3
4
4
^EXIT=10$
5
5
^SIGNAL=0$
6
- \[main.assertion.1\] line \d+ assertion __CPROVER_POINTER_OFFSET\(p\) >= 0: FAILURE
6
+ \[main.assertion.1\] line \d+ assertion __CPROVER_POINTER_OFFSET\(p\) >= 0: SUCCESS
7
7
\[main.assertion.2\] line \d+ assertion __CPROVER_POINTER_OFFSET\(p\) < 0: FAILURE
8
8
--
9
9
^warning: ignoring
10
10
--
11
- For uninitialised pointers, CBMC chooses a nondeterministic value (though no memory
12
- is allocated). Since the offset of pointers is signed, negative offsets should be
13
- able to be chosen (along with positive ones) non-deterministically.
14
- `__CPROVER_POINTER_OFFSET` is the CBMC primitive that gets the pointer offset
15
- from the base address of the object. This test guards this, and especially
16
- against the case where we could only observe some cases where offsets were only
17
- positive (in some CI configurations, for instance).
11
+ For uninitialised pointers, CBMC chooses a nondeterministic value (though no
12
+ memory is allocated). Since the offset of pointers is unsigned, negative
13
+ offsets cannot be chosen. `__CPROVER_POINTER_OFFSET` is the CBMC primitive
14
+ that gets the pointer offset from the base address of the object. This test
15
+ guards this.
Original file line number Diff line number Diff line change 23
23
^\[main.pointer_arithmetic.15\].*: SUCCESS
24
24
^\[main.pointer_arithmetic.16\].*: SUCCESS
25
25
^\[main.pointer_arithmetic.17\].*: SUCCESS
26
- ^\*\* 0 of 20 failed \(1 iterations\)
26
+ ^\[main.pointer_arithmetic.18\].*: SUCCESS
27
+ ^\*\* 0 of 21 failed \(1 iterations\)
27
28
^VERIFICATION SUCCESSFUL$
28
29
--
29
30
^\[main.overflow.\d+\].*: FAILURE
@@ -35,7 +36,7 @@ Checks that assertions generated by the first --pointer-overflow-check:
35
36
We expect 20 assertions to be generated:
36
37
In the goto-instrument run:
37
38
- 2 for using malloc
38
- - 17 caused by --pointer-overflow-check
39
+ - 18 caused by --pointer-overflow-check
39
40
40
41
In the final cbmc run:
41
42
- 0 caused by --pointer-overflow-check
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ void __CPROVER_loop_entry(const void *);
56
56
__CPROVER_bool __CPROVER_LIVE_OBJECT (const void * );
57
57
__CPROVER_bool __CPROVER_WRITEABLE_OBJECT (const void * );
58
58
__CPROVER_size_t __CPROVER_POINTER_OBJECT (const void * );
59
- __CPROVER_ssize_t __CPROVER_POINTER_OFFSET (const void * );
59
+ __CPROVER_size_t __CPROVER_POINTER_OFFSET (const void * );
60
60
__CPROVER_size_t __CPROVER_OBJECT_SIZE (const void * );
61
61
__CPROVER_bool __CPROVER_DYNAMIC_OBJECT (const void * );
62
62
__CPROVER_bool __CPROVER_pointer_in_range (const void * , const void * , const void * );
Original file line number Diff line number Diff line change @@ -194,13 +194,14 @@ literalt bv_pointerst::convert_rest(const exprt &expr)
194
194
if (same_object_lit.is_false ())
195
195
return same_object_lit;
196
196
197
+ // The comparison is UNSIGNED, to match the type of pointer_offsett
197
198
return prop.land (
198
199
same_object_lit,
199
200
bv_utils.rel (
200
201
offset_bv0,
201
202
expr.id (),
202
203
offset_bv1,
203
- bv_utilst::representationt::SIGNED ));
204
+ bv_utilst::representationt::UNSIGNED ));
204
205
}
205
206
}
206
207
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ exprt object_size(const exprt &pointer)
37
37
38
38
exprt pointer_offset (const exprt &pointer)
39
39
{
40
- return pointer_offset_exprt (pointer, signed_size_type ());
40
+ return pointer_offset_exprt (pointer, size_type ());
41
41
}
42
42
43
43
exprt deallocated (const exprt &pointer, const namespacet &ns)
Original file line number Diff line number Diff line change 10
10
TEST_CASE (" pointer_offset_exprt" , " [core][util]" )
11
11
{
12
12
const exprt pointer = symbol_exprt{" foo" , pointer_type (void_type ())};
13
- const pointer_offset_exprt pointer_offset{pointer, signed_size_type ()};
13
+ const pointer_offset_exprt pointer_offset{pointer, size_type ()};
14
14
SECTION (" Is equivalent to free function." )
15
15
{
16
16
CHECK (::pointer_offset (pointer) == pointer_offset);
17
17
}
18
18
SECTION (" Result type" )
19
19
{
20
- CHECK (pointer_offset.type () == signed_size_type ());
20
+ CHECK (pointer_offset.type () == size_type ());
21
21
}
22
22
SECTION (" Pointer operand accessor" )
23
23
{
You can’t perform that action at this time.
0 commit comments