source: CIVL/examples/focus/sv-benchmarks-main-c-array-industry-pattern/c/array-industry-pattern/array_ptr_single_elem_init-1.c

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/* Cannot verify. Reasons:
2 * Correctness of algorithm depends on using array of pointers which are later dereferenced. This causes a CIVL bug to appear.
3 */
4#include <stdlib.h>
5#include <assert.h>
6#pragma CIVL ACSL
7int __VERIFIER_nondet_int(void) {
8 int x;
9 $havoc(&x);
10 return x;
11}
12$input int N;
13$assume(3 < N);
14
15struct S
16{
17 int *p;
18 int n;
19};
20
21struct S *a[ N];
22
23int main()
24{
25
26 int i;
27
28 //init and update
29 //@ transform flatten i;
30 for (i = 0; i < N; i++)
31 {
32 int q = __VERIFIER_nondet_int();
33 struct S *s = NULL;
34 if (q == 0)
35 {
36 s = (struct S*) malloc(sizeof(struct S));
37 s->n = q % 2;
38 }
39 if (s != 0)
40 {
41 if (s->n == 0)
42 {
43 s->p = (int *) malloc(sizeof(int));
44 }
45 else
46 {
47 s->p = NULL;
48 }
49 }
50
51 a[i] = s;
52 }
53
54 a[3] = (struct S*) malloc(sizeof(struct S));
55
56 // modified:
57 //@ transform flatten i;
58 $assert($forall (int i:0..N-1) ((i != 3 && a[i] != NULL && a[i].n == 0) => a[i].p != NULL));
59 /* original:
60 //check 2
61 for (i = 0; i < N; i++)
62 {
63 struct S *s1 = a[i];
64 if (i != 3 && s1 != NULL && s1->n == 0)
65 {
66 __VERIFIER_assert(s1->p != NULL);
67 }
68 }
69 */
70 return 0;
71}
72
Note: See TracBrowser for help on using the repository browser.