source:
CIVL/mods/dev.civl.abc/examples/contract/validPointers.c
| Last change on this file was aad342c, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 336 bytes | |
| Line | |
|---|---|
| 1 | #pragma CIVL ACSL |
| 2 | /*@ |
| 3 | @ requires x >= 0; |
| 4 | @ ensures \result == x + 1; |
| 5 | @ |
| 6 | */ |
| 7 | int add(int x) |
| 8 | { |
| 9 | return x + 1; |
| 10 | } |
| 11 | |
| 12 | /*@ requires \valid(x + (0 .. 2)); |
| 13 | @ ensures *x == \result - 1; |
| 14 | @ ensures \valid(x); |
| 15 | @*/ |
| 16 | int incr(int * x) |
| 17 | { |
| 18 | int ret = *x; |
| 19 | |
| 20 | ret = add(ret); |
| 21 | return ret; |
| 22 | } |
| 23 | |
| 24 | int main() { |
| 25 | incr((void *)-1); |
| 26 | return 0; |
| 27 | } |
Note:
See TracBrowser
for help on using the repository browser.
