source: CIVL/examples/contracts/contractsSeq/pointers2Bad2.c@ bb03188

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