diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/asan/TestCases/use-after-scope-capture.cc | 14 |
1 files changed, 14 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 000000000..28c99b446 --- /dev/null +++ b/test/asan/TestCases/use-after-scope-capture.cc @@ -0,0 +1,14 @@ +// RUN: %clangxx_asan -O0 -fsanitize=use-after-scope %s -o %t && %run %t +// XFAIL: * + +int main() { + std::function<int()> f; + { + int x = 0; + f = [&x]() { + return x; + } + } + return f(); // BOOM + // CHECK: ERROR: AddressSanitizer: stack-use-after-scope +} |