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

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

added a test for the new feature of reporting an error when dereferencing a pointer referring to a scope that is already removed.

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

  • Property mode set to 100644
File size: 577 bytes
Line 
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(){
13 $heap fh;
14 gp = (int *) $malloc(&fh, sizeof(int));
15 gStart = $true;
16 *gp = 1;
17}
18
19void goo(){
20 $when(gStart);
21 *gp = 2;// an error is possible when the process f has already returned.
22}
23
24void main(){
25 $proc f = $spawn foo();
26 $proc g = $spawn goo();
27 $wait f;
28 $wait g;
29}
Note: See TracBrowser for help on using the repository browser.