1.23
2.0
main
test-branch
| Line | |
|---|
| 1 | #include<mem.cvh>
|
|---|
| 2 | #include<stdlib.h>
|
|---|
| 3 |
|
|---|
| 4 | struct T {
|
|---|
| 5 | int a[10];
|
|---|
| 6 | double b[10][10];
|
|---|
| 7 | struct T * t;
|
|---|
| 8 | };
|
|---|
| 9 |
|
|---|
| 10 | int main() {
|
|---|
| 11 | struct T t;
|
|---|
| 12 |
|
|---|
| 13 | for (int i = 0; i < 10; i++) {
|
|---|
| 14 | t.a[i] = i;
|
|---|
| 15 | for (int j = 0; j < 10; j++) {
|
|---|
| 16 | t.b[i][j] = i*10 + j;
|
|---|
| 17 | }
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | $mem m = &t.a[0 .. 5];
|
|---|
| 21 |
|
|---|
| 22 | m = $mem_union(m, &t.b[0..5][0..5]);
|
|---|
| 23 | $mem_havoc(m);
|
|---|
| 24 | $assert(t.a[6] == 6);
|
|---|
| 25 | $assert(t.b[6][0] == 60);
|
|---|
| 26 | t.t = (struct T *)malloc(sizeof(struct T));
|
|---|
| 27 |
|
|---|
| 28 | t.t->a[0] = 0;
|
|---|
| 29 | t.t->a[6] = 6;
|
|---|
| 30 | m = $mem_union(m, &t.t->a[0..5]);
|
|---|
| 31 | $mem_havoc(m);
|
|---|
| 32 | $assert(t.t->a[6] == 6);
|
|---|
| 33 | free(t.t);
|
|---|
| 34 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.