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:
588 bytes
|
| Rev | Line | |
|---|
| [9aaed1f] | 1 | /* This example contains errors:
|
|---|
| 2 | * For "add" function, x is suppose to be a valid pointer.
|
|---|
| 3 | *
|
|---|
| 4 | * For "incr" function, y should be freed before return.
|
|---|
| 5 | */
|
|---|
| 6 | #include <stdlib.h>
|
|---|
| 7 | /*@
|
|---|
| 8 | @ requires val >= 0;
|
|---|
| 9 | @ ensures \result == val + 1;
|
|---|
| 10 | @
|
|---|
| 11 | */
|
|---|
| 12 | int add(int * x, int val)
|
|---|
| 13 | {
|
|---|
| 14 | *x = val + 1;
|
|---|
| 15 | return *x;
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | /*@ requires *x >= 0;
|
|---|
| 19 | @ requires \valid(x);
|
|---|
| 20 | @ ensures *x == \result - 1;
|
|---|
| 21 | @ ensures \valid(x);
|
|---|
| 22 | @*/
|
|---|
| 23 | int incr(int * x)
|
|---|
| 24 | {
|
|---|
| 25 | int * y;
|
|---|
| 26 | int ret;
|
|---|
| 27 |
|
|---|
| 28 | y = (int*)malloc(sizeof(int));
|
|---|
| 29 | *y = *x;
|
|---|
| 30 | ret = add(x, *y);
|
|---|
| 31 | return ret;
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | int main() {
|
|---|
| 35 | incr((void *)-1);
|
|---|
| 36 | return 0;
|
|---|
| 37 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.