17 lines · cpp
1// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && not %run %t >%t.out 2>&12// RUN: FileCheck %s < %t.out && FileCheck %s < %t.out3// RUN: %clangxx_msan -fsanitize-memory-track-origins -O3 %s -o %t && not %run %t >%t.out 2>&14// RUN: FileCheck %s < %t.out && FileCheck %s < %t.out5 6#include <sanitizer/msan_interface.h>7 8int main(int argc, char **argv) {9 int x;10 int *volatile p = &x;11 return __sanitizer_unaligned_load32(p);12 // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value13 // CHECK: {{#0 0x.* in main .*unaligned_read_origin.cpp:}}[[@LINE-2]]14 // CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame15 // CHECK: {{#0 0x.* in main .*unaligned_read_origin.cpp:}}[[@LINE-6]]16}17