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