source: CIVL/examples/languageFeatures/removedHeapPointer.cvl@ c19cfd5

1.23 2.0 main test-branch
Last change on this file since c19cfd5 was c19cfd5, checked in by Manchun Zheng <zmanchun@…>, 12 years ago

added test for bad function prototype like f(), which should be f(void).

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@641 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 616 bytes
RevLine 
[1641d2d]1/* This example shows that CIVL reports an error when
2 * the program tries to dereference a pointer referring
3 * to a unit of a heap that is already removed.
4 * Command line execution:
5 * civl verify removedHeapPointer.cvl
6 */
7#include <civlc.h>
8
9int *gp;
10_Bool gStart = $false;
11
12void foo(){
[c19cfd5]13 $heap fh = $heap_create();
14
15 gp = (int *) $malloc(fh, sizeof(int));
[1641d2d]16 gStart = $true;
17 *gp = 1;
[c19cfd5]18 $free(fh, gp);
[1641d2d]19}
20
21void goo(){
22 $when(gStart);
23 *gp = 2;// an error is possible when the process f has already returned.
24}
25
26void main(){
27 $proc f = $spawn foo();
28 $proc g = $spawn goo();
[c19cfd5]29
[1641d2d]30 $wait f;
31 $wait g;
32}
Note: See TracBrowser for help on using the repository browser.