Move ASan lit-tests under test/asan
[blocksruntime.git] / test / asan / TestCases / use-after-scope-temp.cc
blob13d714f9def78bcae4fd80ea3dc1b5c851a4298c
1 // RUN: %clangxx_asan -O0 -fsanitize=use-after-scope %s -o %t && \
2 // RUN: %t 2>&1 | FileCheck %s
3 //
4 // Lifetime for temporaries is not emitted yet.
5 // XFAIL: *
7 #include <stdio.h>
9 struct IntHolder {
10 explicit IntHolder(int val) : val(val) {
11 printf("IntHolder: %d\n", val);
13 int val;
16 const IntHolder *saved;
18 void save(const IntHolder &holder) {
19 saved = &holder;
22 int main(int argc, char *argv[]) {
23 save(IntHolder(10));
24 int x = saved->val; // BOOM
25 // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
26 // CHECK: #0 0x{{.*}} in main {{.*}}use-after-scope-temp.cc:[[@LINE-2]]
27 printf("saved value: %d\n", x);
28 return 0;