File tree 3 files changed +36
-1
lines changed
regression/contracts/history-pointer-enforce-11
src/goto-instrument/contracts
3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change
1
+ #include <stdlib.h>
2
+
3
+ struct pair
4
+ {
5
+ int x ;
6
+ int y ;
7
+ };
8
+
9
+ void foo (struct pair * p ) __CPROVER_assigns (p - > y )
10
+ __CPROVER_ensures ((p != NULL ) == > (p - > y == __CPROVER_old (p - > y ) + 5 ))
11
+ __CPROVER_ensures ((p == NULL ) == > (p - > y == __CPROVER_old (p - > y )))
12
+ {
13
+ if (p != NULL )
14
+ p -> y = p -> y + 5 ;
15
+ }
16
+
17
+ int main ()
18
+ {
19
+ struct pair * p = NULL ;
20
+ foo (p );
21
+
22
+ return 0 ;
23
+ }
Original file line number Diff line number Diff line change
1
+ KNOWNBUG
2
+ main.c
3
+ --enforce-all-contracts
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^\[postcondition.\d+\] Check ensures clause\: SUCCESS$
7
+ ^\[foo.\d+\] line \d+ Check that p\-\>y is assignable\: SUCCESS$
8
+ ^VERIFICATION SUCCESSFUL$
9
+ --
10
+ --
11
+ This test checks that history variables handle NULL pointers.
12
+ History variables currently do not check for nullness while
13
+ storing values of objects, which may lead to NULL pointer dereferences.
Original file line number Diff line number Diff line change @@ -394,7 +394,6 @@ void code_contractst::replace_old_parameter(
394
394
395
395
const auto ¶meter = to_old_expr (expr).expression ();
396
396
397
- // TODO: generalize below
398
397
if (
399
398
parameter.id () == ID_dereference || parameter.id () == ID_member ||
400
399
parameter.id () == ID_symbol)
You can’t perform that action at this time.
0 commit comments