1 | // This is the ASAN test of the same name ported to HWAsan. |
2 | |
3 | // RUN: %clangxx_hwasan --std=c++11 -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s |
4 | |
5 | // REQUIRES: aarch64-target-arch || riscv64-target-arch |
6 | |
7 | #include <functional> |
8 | |
9 | int main() { |
10 | std::function<int()> f; |
11 | { |
12 | volatile int x = 0; |
13 | f = [&x]() __attribute__((noinline)) { |
14 | return x; // BOOM |
15 | // CHECK: ERROR: HWAddressSanitizer: tag-mismatch |
16 | // We cannot assert the line, after the argument promotion pass this crashes |
17 | // in the BOOM line below instead, when the ref gets turned into a value. |
18 | // CHECK: 0x{{.*}} in {{.*}}use-after-scope-capture.cpp |
19 | // CHECK: Cause: stack tag-mismatch |
20 | }; |
21 | } |
22 | return f(); // BOOM |
23 | } |
24 | |