File tree 2 files changed +55
-0
lines changed
2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include <stdlib.h>
2
+
3
+ struct node
4
+ {
5
+ int value ;
6
+ struct node * next ;
7
+ };
8
+
9
+ struct list
10
+ {
11
+ int size ;
12
+ struct node * head ;
13
+ };
14
+
15
+ void removeLast (struct list * l )
16
+ {
17
+ int index = l -> size - 1 ;
18
+ struct node * * current ;
19
+ for (current = & (l -> head ); index && * current ; index -- )
20
+ current = & (* current )-> next ;
21
+ * current = (* current )-> next ;
22
+ l -> size -- ;
23
+ }
24
+
25
+ int main () {
26
+ //build a 2-nodes list
27
+ struct node * n0 = malloc (sizeof (struct node ));
28
+ struct node * n1 = malloc (sizeof (struct node ));
29
+ struct list * l = malloc (sizeof (struct list ));
30
+ l -> size = 2 ;
31
+ l -> head = n0 ;
32
+
33
+ n0 -> next = n1 ;
34
+ n1 -> next = NULL ;
35
+
36
+ //remove last node from list
37
+
38
+ //this passes
39
+ // struct node **current = &(l->head);
40
+ // current = &(*current)->next;
41
+ // *current = (*current)->next;
42
+ // l->size--;
43
+ //this doesn't
44
+ removeLast (l );
45
+
46
+ __CPROVER_assert (n0 -> next == NULL , "not NULL" );
47
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --unwind 4 --pointer-check --unwinding-assertions
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
You can’t perform that action at this time.
0 commit comments