source: CIVL/examples/focus/sv-benchmarks-main-c-array-industry-pattern/c/array-industry-pattern/array_of_struct_ptr_monotonic.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/* Verifiable with mods:
2 * Loop step of 2 changed to 1
3 * S *a[N] changed to S a[N] due to CIVL bug.
4 */
5typedef unsigned int size_t;
6#include <stdlib.h>
7#include <assert.h>
8#pragma CIVL ACSL
9extern int __VERIFIER_nondet_int(void) {
10 int x;
11 $havoc(&x);
12 return x;
13}
14
15$input int N;
16$assume(0 < N);
17
18struct S
19{
20 int t;
21 int * p1;
22};
23
24// modifed:
25struct S a[N];
26// original:
27//struct S* a[N];
28
29int main()
30{
31 int i;
32 // modified:
33 //@ transform flatten i;
34 for(i = 0; i < N; i++)
35 {
36 struct S s;
37 s.t = __VERIFIER_nondet_int();
38 if (s.t == 10)
39 s.p1 = (int *) malloc(sizeof(int));
40 a[i] = s;
41 }
42 /* original:
43 for(i = 0; i < N; i = i+2)
44 {
45 struct S* s = (struct S*) malloc(sizeof(struct S));
46 s->t = __VERIFIER_nondet_int();
47 if (s->t == 10)
48 s->p1 = (int *) malloc(sizeof(int));
49 a[i] = s;
50 }
51 */
52
53 // modified:
54 //@ transform flatten i;
55 $assert($forall(int i:0..N-1) a[i].t == 10 => a[i].p1 != (void *) 0);
56 /* original:
57 for(i = 0; i < N; i = i+2)
58 {
59 struct S* u = a[i];
60 if (u->t == 10)
61 {
62 __VERIFIER_assert(u->p1 != (void *) 0);
63 }
64 }
65 */
66}
Note: See TracBrowser for help on using the repository browser.