main
test-branch
|
Last change
on this file since 7320499 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.2 KB
|
| Line | |
|---|
| 1 | /* Verifiable with mods:
|
|---|
| 2 | * Changed S *a[N] to S a[N] because of CIVL bug: Pointer symbolic info not simplified before dereference. Trying to fix this leads to deeper CIVL bug.
|
|---|
| 3 | */
|
|---|
| 4 | typedef unsigned int size_t;
|
|---|
| 5 | #include <stdlib.h>
|
|---|
| 6 | #include <assert.h>
|
|---|
| 7 | #pragma CIVL ACSL
|
|---|
| 8 |
|
|---|
| 9 | extern int __VERIFIER_nondet_int(void) {
|
|---|
| 10 | int x;
|
|---|
| 11 | $havoc(&x);
|
|---|
| 12 | return x;
|
|---|
| 13 | }
|
|---|
| 14 | $input int N;
|
|---|
| 15 | $assume(0 < N);
|
|---|
| 16 | struct _S
|
|---|
| 17 | {
|
|---|
| 18 | int *p;
|
|---|
| 19 | int n;
|
|---|
| 20 | };
|
|---|
| 21 | typedef struct _S S;
|
|---|
| 22 |
|
|---|
| 23 | S *a[N];
|
|---|
| 24 | int user_read()
|
|---|
| 25 | {
|
|---|
| 26 | int x = __VERIFIER_nondet_int();
|
|---|
| 27 | return x;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | int main()
|
|---|
| 31 | {
|
|---|
| 32 | int i;
|
|---|
| 33 |
|
|---|
| 34 | //@ transform flatten I;
|
|---|
| 35 | for(i = 0; i < N; i++)
|
|---|
| 36 | {
|
|---|
| 37 | S *s1 = (S *)malloc(sizeof(S));
|
|---|
| 38 |
|
|---|
| 39 | s1 -> n = user_read();
|
|---|
| 40 |
|
|---|
| 41 | if(s1 ->n == 1)
|
|---|
| 42 | {
|
|---|
| 43 | s1 -> p = (int *)malloc(sizeof(int));
|
|---|
| 44 | }
|
|---|
| 45 | else
|
|---|
| 46 | {
|
|---|
| 47 | s1 -> p = (void *)0;
|
|---|
| 48 | }
|
|---|
| 49 | a[i] = s1;
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | // Modified
|
|---|
| 53 | //@ transform flatten I;
|
|---|
| 54 | $assert($forall(int i:0..N-1) (a[i]->n == 1) == (a[i]->p != (void *)0));
|
|---|
| 55 | // Original
|
|---|
| 56 | /*
|
|---|
| 57 | for(i = 0; i < N; i++)
|
|---|
| 58 | {
|
|---|
| 59 | S *s2 = a[i];
|
|---|
| 60 |
|
|---|
| 61 | if(s2 ->n == 1)
|
|---|
| 62 | {
|
|---|
| 63 | __VERIFIER_assert(s2 -> p != (void *)0);
|
|---|
| 64 | }
|
|---|
| 65 | }
|
|---|
| 66 | */
|
|---|
| 67 |
|
|---|
| 68 | /*
|
|---|
| 69 | //@ transform flatten I;
|
|---|
| 70 | for(i = 0; i < N; i++)
|
|---|
| 71 | {
|
|---|
| 72 | if (a[i]->n == 1) {
|
|---|
| 73 | free(a[i]->p);
|
|---|
| 74 | }
|
|---|
| 75 | free(a[i]);
|
|---|
| 76 | }
|
|---|
| 77 | */
|
|---|
| 78 | return 0;
|
|---|
| 79 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.