main
|
Last change
on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago |
|
Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
462 bytes
|
| Rev | Line | |
|---|
| [9aaed1f] | 1 | #include <stdlib.h>
|
|---|
| 2 | /*@ requires \valid(x);
|
|---|
| 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 | @ requires x[1] >= 0;
|
|---|
| 14 | @ ensures x[1] == \result - 1;
|
|---|
| 15 | @ ensures \valid(x + (0 .. 2));
|
|---|
| 16 | @*/
|
|---|
| 17 | int incr(int * x)
|
|---|
| 18 | {
|
|---|
| 19 | int * y;
|
|---|
| 20 | int ret;
|
|---|
| 21 |
|
|---|
| 22 | y = (int*)malloc(sizeof(int));
|
|---|
| 23 | *y = x[1];
|
|---|
| 24 | ret = add(&x[1]);
|
|---|
| 25 | free(y);
|
|---|
| 26 | return ret;
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | int main() {
|
|---|
| 30 | incr((void *)-1);
|
|---|
| 31 | return 0;
|
|---|
| 32 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.