1 // This is the ASAN test of the same name ported to HWAsan.
2 
3 // RUN: %clangxx_hwasan -mllvm -hwasan-use-after-scope -std=c++11 -O1 %s -o %t && \
4 // RUN:     not %run %t 2>&1 | FileCheck %s
5 
6 // REQUIRES: aarch64-target-arch
7 // REQUIRES: stable-runtime
8 
9 struct IntHolder {
10   int val;
11 };
12 
13 const IntHolder *saved;
14 
save(const IntHolder & holder)15 __attribute__((noinline)) void save(const IntHolder &holder) {
16   saved = &holder;
17 }
18 
main(int argc,char * argv[])19 int main(int argc, char *argv[]) {
20   save({argc});
21   int x = saved->val; // BOOM
22   // CHECK: ERROR: HWAddressSanitizer: tag-mismatch
23   // CHECK:  #0 0x{{.*}} in main {{.*}}use-after-scope-temp.cpp:[[@LINE-2]]
24   // CHECK: Cause: stack tag-mismatch
25   return x;
26 }
27