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 | /* Bug found in assertion!
|
|---|
| 2 | * Fixed and verified (although missing uninitialized array element read bug)
|
|---|
| 3 | */
|
|---|
| 4 | #include <stdlib.h>
|
|---|
| 5 | #include <assert.h>
|
|---|
| 6 | #pragma CIVL ACSL
|
|---|
| 7 | int __VERIFIER_nondet_int(void) {
|
|---|
| 8 | int x;
|
|---|
| 9 | $havoc(&x);
|
|---|
| 10 | return x;
|
|---|
| 11 | }
|
|---|
| 12 | $input int N;
|
|---|
| 13 | $assume(15000 < N);
|
|---|
| 14 |
|
|---|
| 15 | int main()
|
|---|
| 16 | {
|
|---|
| 17 |
|
|---|
| 18 | int i;
|
|---|
| 19 | int a[N];
|
|---|
| 20 | int b[N];
|
|---|
| 21 | int c[N];
|
|---|
| 22 |
|
|---|
| 23 | //init and update
|
|---|
| 24 | //@ transform flatten i;
|
|---|
| 25 | for (i = 0; i < N; i++)
|
|---|
| 26 | {
|
|---|
| 27 | int q = __VERIFIER_nondet_int();
|
|---|
| 28 | a[i] = 0;
|
|---|
| 29 | if (q == 0)
|
|---|
| 30 | {
|
|---|
| 31 | a[i] = 1;
|
|---|
| 32 | b[i] = i % 2;
|
|---|
| 33 | }
|
|---|
| 34 | if (a[i] != 0)
|
|---|
| 35 | {
|
|---|
| 36 | if (b[i] == 0)
|
|---|
| 37 | {
|
|---|
| 38 | c[i] = 0;
|
|---|
| 39 | }
|
|---|
| 40 | else
|
|---|
| 41 | {
|
|---|
| 42 | c[i] = 1;
|
|---|
| 43 | }
|
|---|
| 44 | }
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | a[15000] = 1;
|
|---|
| 48 |
|
|---|
| 49 | // fixed (mimicing structure of array_ptr_single_elem_init-1.c)
|
|---|
| 50 | //@ transform flatten i;
|
|---|
| 51 | $assert($forall(int j:0..N-1) ((j != 15000 && a[j] != 0 && b[j] == 0) => c[j] == 0));
|
|---|
| 52 |
|
|---|
| 53 | //$assert($forall (int i:0..N-1) ((i != 3 && a[i] != NULL && a[i].n == 0) => a[i].p != NULL));
|
|---|
| 54 | /* modified (with bug):
|
|---|
| 55 | // transform flatten i;
|
|---|
| 56 | $assert($forall(int i:0..N-1) i == 15000 => a[i] != 1);
|
|---|
| 57 | */
|
|---|
| 58 | /* original:
|
|---|
| 59 | for (i = 0; i < N; i++)
|
|---|
| 60 | {
|
|---|
| 61 | if(i==15000)
|
|---|
| 62 | {
|
|---|
| 63 | __VERIFIER_assert(a[i] != 1);
|
|---|
| 64 | }
|
|---|
| 65 | }
|
|---|
| 66 | */
|
|---|
| 67 | return 0;
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.