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 && not %run %t 2>&1 | FileCheck %s
4
5 // REQUIRES: aarch64-target-arch
6 // REQUIRES: stable-runtime
7
8 #include <functional>
9
main()10 int main() {
11 std::function<int()> f;
12 {
13 int x = 0;
14 f = [&x]() __attribute__((noinline)) {
15 return x; // BOOM
16 // CHECK: ERROR: HWAddressSanitizer: tag-mismatch
17 // CHECK: #0 0x{{.*}} in {{.*}}use-after-scope-capture.cpp:[[@LINE-2]]
18 // CHECK: Cause: stack tag-mismatch
19 };
20 }
21 return f(); // BOOM
22 }
23