File: array_array.c

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 (73 lines) | stat: -rw-r--r-- 1,342 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
/* run.config*
   
   STDOPT: #"-main main"
   STDOPT: #"-main main2"
   STDOPT: #"-main main3"
*/


char StaticAllocHEAP[10000]={2,2,2,2};
void *LIB_MEM_StaticAlloc(int size, int hint) {

  static int next_free=0;
  Frama_C_show_each_ALLOCATION_WITH_STATIC_ALLOC(size);
  void * new = &(StaticAllocHEAP[next_free]);
/* Enforce a 4 byte boundary for allocation */
  next_free += (size%4==0)?size:size+4-size%4;
  return new;
}

struct S {int fst; char snd;};
#define MAX 3
void main() {
  struct S (*v)[MAX];
  v = (struct S(*)[MAX]) LIB_MEM_StaticAlloc(sizeof(struct S) * MAX, 0);
  int i = 29;
  do {
    Frama_C_show_each_I(i);
    v[0][i].snd=1;}
  while (i-- > -1);

  v[0][i].fst = 0;
}


void main2(void)
{ struct S (*v)[3] ;
  int i ;
  int tmp___0 = 0;

  {
  v = (struct S (*)[3])LIB_MEM_StaticAlloc((int )(sizeof(struct S ) * 3U), 0);
  i = 29;
  {

  while (1) {
    Frama_C_show_each_TMP(tmp___0);
    Frama_C_show_each_I(i);
    (*(v + 0))[i].snd = (char)1;
    tmp___0 = i;
    i --;
    if (! (tmp___0 > -1)) {
      goto while_0_break;
    }
  }

  while_0_break: /* CIL Label */ ;
  }
  (*(v + 0))[i].fst = 0;

  return;
}
}

void main3() {
  struct S (*v)[MAX];
  v = (struct S(*)[MAX]) LIB_MEM_StaticAlloc(sizeof(struct S) * MAX, 0);
  int i = 29;
  do {
    v[0][i].snd=1;
    i--;}
  while (i > 0);
  v[0][i].fst = 0;
}