Index: test/asan/TestCases/use-after-scope-capture.cc =================================================================== --- /dev/null +++ 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 f; + { + int x = 0; + f = [&x]() { + return x; + } + } + return f(); // BOOM + // CHECK: ERROR: AddressSanitizer: stack-use-after-scope +}