Files
clang-p2996/compiler-rt/test/asan/TestCases/use-after-scope-capture.cpp
Vitaly Buka cd269daf25 [test][asan] Remove -fsanitize-address-use-after-scope
It's enabled by default in D31479.
2022-08-13 00:04:55 -07:00

17 lines
396 B
C++

// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
#include <functional>
int main() {
std::function<int()> f;
{
int x = 0;
f = [&x]() __attribute__((noinline)) {
return x; // BOOM
// CHECK: ERROR: AddressSanitizer: stack-use-after-scope
// CHECK: #0 0x{{.*}} in {{.*}}use-after-scope-capture.cpp:[[@LINE-2]]
};
}
return f(); // BOOM
}