File: unspecified_access_address.i

package info (click to toggle)
frama-c 20201209%2Btitanium-4.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 55,200 kB
  • sloc: ml: 260,374; ansic: 51,885; sh: 3,578; makefile: 3,111; python: 1,029; perl: 897; lisp: 259; xml: 62; asm: 46
file content (19 lines) | stat: -rw-r--r-- 414 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* run.config
STDOPT: +"-kernel-msg-key printer:unspecified"
*/

int f(int *p, int x) {
  *p = x + 1;
  return x;
}

int g() {
  int x = 3;
  int y = f(&x, ++x); // correct: we're not reading x, but &x
  int a[10] = { 0 };
  int *b = a;
  int z = f(&b[x], b[2]);
  int t = f(&b[x], ++x); // incorrect: write and read access to x;
  int u = f(&b[2], *(b++)); // incorrect: write and read access to b;
  return y;
}