diff options
Diffstat (limited to 'test/asan/TestCases/use-after-scope-capture.cc')
-rw-r--r-- | test/asan/TestCases/use-after-scope-capture.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/asan/TestCases/use-after-scope-capture.cc b/test/asan/TestCases/use-after-scope-capture.cc new file mode 100644 index 0000000000000..07aab672eecb3 --- /dev/null +++ b/test/asan/TestCases/use-after-scope-capture.cc @@ -0,0 +1,17 @@ +// RUN: %clangxx_asan -std=c++11 -O1 -fsanitize-address-use-after-scope %s -o %t && \ +// RUN: not %run %t 2>&1 | FileCheck %s + +#include <functional> + +int main() { + std::function<int()> f; + { + int x = 0; + f = [&x]() { + return x; // BOOM + // CHECK: ERROR: AddressSanitizer: stack-use-after-scope + // CHECK: #0 0x{{.*}} in {{.*}}use-after-scope-capture.cc:[[@LINE-2]] + }; + } + return f(); // BOOM +} |