]> git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/asan/TestCases/use-after-scope-temp.cc
New upstream version 1.12.0+dfsg1
[rustc.git] / src / compiler-rt / test / asan / TestCases / use-after-scope-temp.cc
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
13 void save(const IntHolder &holder) {
14 saved = &holder;
15 }
16
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 }