File: offsetmap.i

package info (click to toggle)
frama-c 20220511-manganese-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 66,492 kB
  • sloc: ml: 278,834; ansic: 47,093; sh: 4,823; makefile: 3,613; javascript: 2,436; python: 1,919; perl: 897; lisp: 293; xml: 62
file content (77 lines) | stat: -rw-r--r-- 1,285 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* run.config*
   
   STDOPT: #""
   STDOPT: #"-eva-warn-copy-indeterminate=-f,-g"
*/

int TT[10]={1,2,3};
int T[10]={1,2,3};
int i,a,b;
int a7, b7;

int O1[20];
int O2[20];
int *p;

int x2,*b2,a2;

void f() {
  for (i = 0; i <= 8; i++) {
    TT[i] = i;
    *((int*)((char*)&(TT[i]) + 1)) = 0;
  }

  a = 1;
  if (b) i=5; else i=6;
  a=3;
  if (i>=2) { a = i ; T[i] = 7 ; }

  for (i = 0; i <= 8; i++) {
    *(char *) &a = 1;
    b = a;

    *((int*)(((char*)&(T[i])) + 1)) = 0;
  }

  a7 = 'a';
  *(char *) &a7 = 1;
  b7 = (char)a7;

  ((int*)O1)[1]=17;
  ((char*)O1)[1]=18;

  ((int*)O2)[0]=10;
  ((char*)O2)[1]=11;

  O1[6]=0;
  p=O1+9;
  *p=1;

  x2 = 777;
  a2 = (int)&x2;
  b2 = (int*) a2;
  *((int*)a2) = 0;
  *b2=*b2+1;
}


int s[10000000];

/* Performance test on reading a value in an offsetmap. Here the offsetmap for s
   contains one value of 4 bytes repeated 10000000 times, and we read 1 byte at
   an unknown position in this offsetmap. 4 consecutive reads of 1 byte each are
   required to be sound. Doing 40000000 reads would be harshly inefficient
   (leading the analysis to not terminate on this function).  */
void g(int i) {
  s[i] = 0x1030807;
  char *p = &s[i];
  char c1 = *p;
  char *q = (char*)&s+i;
  char c2 = *q;
}


void main (int i) {
  f();
  g(i);
}