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 {
SelfIntHolder10   __attribute__((noinline)) const IntHolder &Self() const {
11     return *this;
12   }
13   int val = 3;
14 };
15 
16 const IntHolder *saved;
17 
main(int argc,char * argv[])18 int main(int argc, char *argv[]) {
19   saved = &IntHolder().Self();
20   int x = saved->val; // BOOM
21   // CHECK: ERROR: HWAddressSanitizer: tag-mismatch
22   // CHECK:  #0 0x{{.*}} in main {{.*}}use-after-scope-temp2.cpp:[[@LINE-2]]
23   // CHECK: Cause: stack tag-mismatch
24   return x;
25 }
26