// RUN: %clangxx_asan %stdcxx11 -O1 -fsanitize-address-use-after-scope %s -o %t && \
// RUN:     not %run %t 2>&1 | FileCheck %s


struct IntHolder {
  const IntHolder& Self() const {
    return *this;
  }
  int val = 3;
};

const IntHolder *saved;

int main(int argc, char *argv[]) {
  saved = &IntHolder().Self();
  int x = saved->val;  // BOOM
  // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
  // CHECK:  #0 0x{{.*}} in main {{.*}}use-after-scope-temp2.cc:[[@LINE-2]]
  return x;
}

Add test which detects bugs undetectable before r288563
[asan] Add test which detects bugs undetectable before r288563

Reviewers: kcc, eugenis

Subscribers: llvm-commits, kubabrecka

Differential Revision: https://reviews.llvm.org/D27583

git-svn-id: c199f293c43da69278bea8e88f92242bf3aa95f7@289090 91177308-0d34-0410-b5e6-96231b3b80d8
