2021-08-02 15:58:49 +08:00
|
|
|
// This is the ASAN test of the same name ported to HWAsan.
|
|
|
|
|
|
|
|
// RUN: %clangxx_hwasan -mllvm -hwasan-use-after-scope --std=c++11 -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
|
|
|
|
|
|
|
|
// REQUIRES: aarch64-target-arch
|
2021-07-16 23:30:37 +08:00
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
std::function<int()> f;
|
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
f = [&x]() __attribute__((noinline)) {
|
2021-07-19 18:16:38 +08:00
|
|
|
return x; // BOOM
|
2021-08-02 15:58:49 +08:00
|
|
|
// CHECK: ERROR: HWAddressSanitizer: tag-mismatch
|
2021-07-16 23:30:37 +08:00
|
|
|
// CHECK: #0 0x{{.*}} in {{.*}}use-after-scope-capture.cpp:[[@LINE-2]]
|
2021-08-02 15:58:49 +08:00
|
|
|
// CHECK: Cause: stack tag-mismatch
|
2021-07-16 23:30:37 +08:00
|
|
|
};
|
|
|
|
}
|
2021-07-19 18:16:38 +08:00
|
|
|
return f(); // BOOM
|
2021-07-16 23:30:37 +08:00
|
|
|
}
|