Example: provenance_equality_uintptr_t_auto_yx.c

up: index
prev: provenance_equality_uintptr_t_auto_xy.c
next: provenance_union_punning_2_global_xy.c

1
2
3
4
5
6
7
8
9
10
11
12
13
    #include <stdio.h>
    #include <inttypes.h> 
    int main() {
      int y=2, x=1;
      uintptr_t p = (uintptr_t)(&x + 1);
      uintptr_t q = (uintptr_t)&y;
      printf("Addresses: p=%" PRIxPTR " q=%" PRIxPTR "\n",
             (unsigned long)p,(unsigned long)q);
      _Bool b = (p==q);
      // can this be false even with identical addresses?
      printf("(p==q) = %s\n", b?"true":"false");
      return 0;
    }
[link to run test in Cerberus]

Experimental data (what does this mean?)

cerberus-concrete-PVI-plain Addresses: p=ffffedd8 q=ffffedd8
(p==q) = true
cerberus-concrete-PVI-ae Addresses: p=ffffedd8 q=ffffedd8
(p==q) = true
cerberus-concrete-PVI-ae-udi Addresses: p=ffffedd8 q=ffffedd8
(p==q) = true
gcc-8.3-O0 Addresses: p=7ffeefbff2e8 q=7ffeefbff2e8
(p==q) = true
gcc-8.3-O2 Addresses: p=7ffeefbff300 q=7ffeefbff2f8
(p==q) = false
gcc-8.3-O3 Addresses: p=7ffeefbff300 q=7ffeefbff2f8
(p==q) = false
gcc-8.3-O2-no-strict-aliasing Addresses: p=7ffeefbff2d0 q=7ffeefbff2c8
(p==q) = false
gcc-8.3-O3-no-strict-aliasing Addresses: p=7ffeefbff2d0 q=7ffeefbff2c8
(p==q) = false
clang-7.0.1-O0 Addresses: p=7ffeefbff2f8 q=7ffeefbff2f8
(p==q) = true
clang-7.0.1-O2 Addresses: p=7ffeefbff2f0 q=7ffeefbff2e8
(p==q) = false
clang-7.0.1-O3 Addresses: p=7ffeefbff2f0 q=7ffeefbff2e8
(p==q) = false
clang-7.0.1-O2-no-strict-aliasing Addresses: p=7ffeefbff2b0 q=7ffeefbff2a8
(p==q) = false
clang-7.0.1-O3-no-strict-aliasing Addresses: p=7ffeefbff2b0 q=7ffeefbff2a8
(p==q) = false
icc-19-O0 Addresses: p=7fffffffe6ac q=7fffffffe6a4
(p==q) = false
icc-19-O2 Addresses: p=6046c4 q=6046c4
(p==q) = true
icc-19-O3 Addresses: p=6046c4 q=6046c4
(p==q) = true
icc-19-O2-no-strict-aliasing Addresses: p=6046c4 q=6046c4
(p==q) = true
icc-19-O3-no-strict-aliasing Addresses: p=6046c4 q=6046c4
(p==q) = true