summaryrefslogtreecommitdiff
path: root/test/msan/loop-scope.cpp
blob: 638bdbe173241326a9052510cfc3a8c6d3c62e32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 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]]
}