Example: provenance_roundtrip_via_intptr_t_onepast.c

up: index
prev: provenance_lost_escape_1.c
next: pointer_from_int_disambiguation_1.c

1
2
3
4
5
6
7
8
9
10
11
12
    #include <stdio.h>
    #include <inttypes.h>
    int x=1;
    int main() {
      int *p = &x;
      p=p+1;
      intptr_t i = (intptr_t)p;
      int *q = (int *)i;
      q=q-1;
      *q = 11; // is this free of undefined behaviour?
      printf("*q=%d\n",*q);  
    }
[link to run test in Cerberus]

Experimental data (what does this mean?)

cerberus-concrete-PVI-plain Killed {msg: MerrOther "out-of-bound pointer arithmetic (Prov_none)"}
cerberus-concrete-PVI-ae Killed {msg: MerrOther "out-of-bound pointer arithmetic (Prov_none)"}
cerberus-concrete-PVI-ae-udi *q=11
gcc-8.3-O0 *q=11
gcc-8.3-O2 *q=11
gcc-8.3-O3 *q=11
gcc-8.3-O2-no-strict-aliasing *q=11
gcc-8.3-O3-no-strict-aliasing *q=11
clang-7.0.1-O0 *q=11
clang-7.0.1-O2 *q=11
clang-7.0.1-O3 *q=11
clang-7.0.1-O2-no-strict-aliasing *q=11
clang-7.0.1-O3-no-strict-aliasing *q=11
icc-19-O0 *q=11
icc-19-O2 *q=11
icc-19-O3 *q=11
icc-19-O2-no-strict-aliasing *q=11
icc-19-O3-no-strict-aliasing *q=11