Additional test for use-after-scope

Summary: Test that asan detects access to the dead variable captured by lambda.

Reviewers: aizatsky, kcc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D19238

llvm-svn: 266676
This commit is contained in:
Kostya Serebryany 2016-04-18 21:36:34 +00:00
parent e6643daa18
commit d8ce87f850
1 changed files with 14 additions and 0 deletions

View File

@ -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
}