1 // RUN: %clangxx_asan -O1 -fsanitize-address-use-after-scope %s -o %t && \
2 // RUN:     not %run %t 2>&1 | FileCheck %s
3 //
4 // Lifetime for temporaries is not emitted yet.
5 // XFAIL: *
6 
7 struct IntHolder {
8   int val;
9 };
10 
11 const IntHolder *saved;
12 
save(const IntHolder & holder)13 void save(const IntHolder &holder) {
14   saved = &holder;
15 }
16 
main(int argc,char * argv[])17 int main(int argc, char *argv[]) {
18   save({10});
19   int x = saved->val;  // BOOM
20 // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
21 // CHECK:  #0 0x{{.*}} in main {{.*}}use-after-scope-temp.cc:[[@LINE-2]]
22   return x;
23 }
24