1.23
2.0
acw/focus-triggers
main
test-branch
| Line | |
|---|
| 1 | /* civlValueUndefined : This example lists several cases of misusage of
|
|---|
| 2 | $scope, $proc and pointer types. It is used for code coverage, so
|
|---|
| 3 | the program may not meaningful. */
|
|---|
| 4 | #include<civlc.cvh>
|
|---|
| 5 | #include<stdlib.h>
|
|---|
| 6 | $scope scope;
|
|---|
| 7 | double * ptr;
|
|---|
| 8 | void getInvalidScope() {
|
|---|
| 9 | scope = $here;
|
|---|
| 10 | ptr = (double*)malloc(sizeof(double));
|
|---|
| 11 | free(ptr);
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | int main() {
|
|---|
| 15 | $scope root = $root;
|
|---|
| 16 | $proc proc0, proc1;
|
|---|
| 17 | int a = 0;
|
|---|
| 18 |
|
|---|
| 19 | proc0 = $spawn getInvalidScope();
|
|---|
| 20 | $wait(proc0);
|
|---|
| 21 | proc1 = proc0;
|
|---|
| 22 | //so far, scope, proc0 and proc1 are all undefined; ptr is to a
|
|---|
| 23 | //memory space which belongs to an undefined scope.
|
|---|
| 24 | $choose{
|
|---|
| 25 | $when($true) {a = scope == root;}
|
|---|
| 26 | $when($true) {a = proc0 == proc1;}
|
|---|
| 27 | $when($true) {a = ptr == (void*)0;}
|
|---|
| 28 | }
|
|---|
| 29 | return 0;
|
|---|
| 30 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.