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