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