Example: pointer_from_integer_1i.c

up: index
prev: pointer_from_integer_1p.c
next: pointer_from_integer_2.c

1
2
3
4
5
6
7
8
9
10
11
12
13
    #include <stdio.h>
    #include <stdint.h>
    #include "charon_address_guesses.h"
    void f(uintptr_t i) {
      int j=5; 
      int *p = (int*)i;
      *p=7;
      printf("j=%d\n",j); 
    }
    int main() {
      uintptr_t j = ADDRESS_PFI_1I;
      f(j);
    }
[link to run test in Cerberus]

Experimental data (what does this mean?)

cerberus-concrete-PVI Undefined behaviour: the operand of the unary '*' operator has an invalid value at 7:3-5
cerberus-concrete-PNVI j=7
gcc-8.1-O0 exit codes: compile 0 / execute 139 Segmentation fault (core dumped)
gcc-8.1-O2 j=5
gcc-8.1-O3 j=5
gcc-8.1-O2-no-strict-aliasing j=5
gcc-8.1-O3-no-strict-aliasing j=5
clang-6.0-O0 j=5
clang-6.0-O2 j=5
clang-6.0-O3 j=5
clang-6.0-O2-no-strict-aliasing j=5
clang-6.0-O3-no-strict-aliasing j=5
clang-6.0-UBSAN j=5
clang-6.0-ASAN j=5
clang-6.0-MSAN j=5
icc-19-O0 j=5
icc-19-O2 j=5
icc-19-O3 j=5
icc-19-O2-no-strict-aliasing j=5
icc-19-O3-no-strict-aliasing j=5
compcert-3.4 exit codes: compile 0 / execute 139 Segmentation fault (core dumped)
compcert-3.4-O exit codes: compile 0 / execute 139 Segmentation fault (core dumped)
kcc-1.0 exit codes: compile 0 / execute 139 Conversion from an integer to non-null pointer:
> in f at pointer_from_integer_1i.c:6:3
in main at pointer_from_integer_1i.c:12:3

Implementation defined behavior (IMPL-CCV13):
see C11 section 6.3.2.3:5 http://rvdoc.org/C11/6.3.2.3
see CERT section INT36-C http://rvdoc.org/CERT/INT36-C