view compiler-rt/test/msan/loop-scope.cpp @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 1d019706d866
children
line wrap: on
line source

// RUN: %clangxx_msan -O2 %s -o %t && \
// RUN:     not %run %t 2>&1 | FileCheck %s

#include <stdlib.h>

int *p;

int main() {
  for (int i = 0; i < 3; i++) {
    int x;
    if (i == 0)
      x = 0;
    p = &x;
  }
  return *p; // BOOM
  // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
  // CHECK:  #0 0x{{.*}} in main {{.*}}loop-scope.cpp:[[@LINE-2]]
}