You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
455 B
18 lines
455 B
// RUN: %clangxx_asan %stdcxx11 -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]() __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
|
|
}
|