source:
CIVL/examples/languageFeatures/pointersBad.cvl@
fb371c8
| Last change on this file since fb371c8 was fb371c8, checked in by , 11 years ago | |
|---|---|
|
|
| File size: 491 bytes | |
| Rev | Line | |
|---|---|---|
| [262ecde] | 1 | /* Commandline execution: |
| 2 | * civl verify pointersBad.cvl | |
| 3 | * */ | |
| 4 | #include<civlc.cvh> | |
| 5 | #include<stdlib.h> | |
| 6 | ||
| 7 | $output int out; | |
| [f79e288] | 8 | $input int x; |
| [050ee5d] | 9 | $input int *x_ptr; |
| [262ecde] | 10 | void main() { |
| 11 | int a; | |
| [f79e288] | 12 | int* b, *c; |
| 13 | int * nilPtr = NULL; | |
| [262ecde] | 14 | |
| [f79e288] | 15 | c = (void *)(-1); |
| [262ecde] | 16 | b = (int *)malloc(sizeof(int)); |
| 17 | free(b); | |
| [f79e288] | 18 | $choose { |
| [fb371c8] | 19 | $when(x == 3) {a = *(&out);} |
| [050ee5d] | 20 | $when(x == 2) {a = *x_ptr;} |
| 21 | $when(x == 1) {c = &a + 1; a = *c;} | |
| [f79e288] | 22 | $when(x == 0) {a = *c;} |
| [fb371c8] | 23 | $when(x >= 4) {a = *b;} |
| 24 | $when(x < 0) {a = *nilPtr;} | |
| [f79e288] | 25 | } |
| [262ecde] | 26 | } |
Note:
See TracBrowser
for help on using the repository browser.
