1 // RUN: %clangxx_nsan -O0 -g %s -o %t 2 // RUN: %run %t 2>&1 | FileCheck %s 3 4 // RUN: %clangxx_nsan -O3 -g %s -o %t 5 // RUN: %run %t 2>&1 | FileCheck %s 6 7 #include <cstddef> 8 9 #include "helpers.h" 10 11 extern "C" void __nsan_dump_shadow_mem(const char *addr, size_t size_bytes, 12 size_t bytes_per_line, size_t reserved); 13 14 int main() { 15 int size = 3 * sizeof(float); 16 // Make sure we allocate dynamically: https://godbolt.org/z/T3h998. 17 DoNotOptimize(size); 18 float *array = reinterpret_cast<float *>(__builtin_alloca(size)); 19 DoNotOptimize(array); 20 array[0] = 1.0; 21 array[1] = 2.0; 22 // The third float is uninitialized. 23 __nsan_dump_shadow_mem((const char *)array, 3 * sizeof(float), 16, 0); 24 // CHECK: {{.*}} f0 f1 f2 f3 f0 f1 f2 f3 __ __ __ __ (1.00000000000000000000) (2.00000000000000000000) 25 return 0; 26 } 27