1 // RUN: %clangxx_asan -O1 -fsanitize-address-use-after-scope %s -o %t && \
2 // RUN:     not %run %t 2>&1 | FileCheck %s
3 
4 struct IntHolder {
SelfIntHolder5   __attribute__((noinline)) const IntHolder &Self() const {
6     return *this;
7   }
8   int val = 3;
9 };
10 
11 const IntHolder *saved;
12 
main(int argc,char * argv[])13 int main(int argc, char *argv[]) {
14   saved = &IntHolder().Self();
15   int x = saved->val;  // BOOM
16   // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
17   // CHECK:  #0 0x{{.*}} in main {{.*}}use-after-scope-temp2.cpp:[[@LINE-2]]
18   return x;
19 }
20