20 lines · cpp
1// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s2 3#include "defines.h"4#include <functional>5 6int main() {7 std::function<int()> f;8 {9 int x = 0;10 f = [&x]() ATTRIBUTE_NOINLINE {11 return x; // BOOM12 // CHECK: ERROR: AddressSanitizer: stack-use-after-scope13 // We cannot assert the line, after the argument promotion pass this crashes14 // in the BOOM line below instead, when the ref gets turned into a value.15 // CHECK: #0 0x{{.*}} in {{.*}}use-after-scope-capture.cpp16 };17 }18 return f(); // BOOM19}20