main
test-branch
| Rev | Line | |
|---|
| [9aaed1f] | 1 | #include <stdlib.h>
|
|---|
| 2 | /*@ requires \valid(x);
|
|---|
| 3 | @ ensures \result == *x + 1;
|
|---|
| 4 | @
|
|---|
| 5 | */
|
|---|
| 6 | int add(int * x)
|
|---|
| 7 | {
|
|---|
| 8 | return *x + 1;
|
|---|
| 9 | }
|
|---|
| 10 |
|
|---|
| 11 | /*@ requires \valid(x);
|
|---|
| 12 | @ requires *x >= 0;
|
|---|
| 13 | @ ensures *x == \result - 1;
|
|---|
| 14 | @*/
|
|---|
| 15 | int incr(int * x)
|
|---|
| 16 | {
|
|---|
| 17 | int * y;
|
|---|
| 18 | int ret;
|
|---|
| 19 |
|
|---|
| 20 | y = (int*)malloc(sizeof(int));
|
|---|
| 21 | ret = add(x);
|
|---|
| 22 | free(y);
|
|---|
| 23 | return ret;
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | int main() {
|
|---|
| 27 | incr((void *)-1);
|
|---|
| 28 | return 0;
|
|---|
| 29 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.