// { dg-do compile { target c++14 } }
// { dg-skip-if "requires hosted libstdc++ for iostream" { ! hostedlib } }

#include <iostream>
auto lol()
{
    int aha = 3;
    return [&aha] {
        return aha; // { dg-warning "dereferencing pointer '.*' to within stale stack frame" }
    };
    /* TODO: may be worth special-casing the reporting of dangling
       references from lambdas, to highlight the declaration, and maybe fix
       the wording (it's a reference, not a pointer, for one thing).  */
}

int main()
{
    auto lambda = lol();
    std::cout << lambda() << std::endl;
    return 0;
}