Fortran: Fix PR 47485.
[gcc.git] / gcc / testsuite / g++.dg / analyzer / pr93212.C
blob0c7c134d262aa6b4a6c3d088a4af1dbcce6a150a
1 // { dg-do compile { target c++14 } }
2 // { dg-skip-if "requires hosted libstdc++ for iostream" { ! hostedlib } }
4 #include <iostream>
5 auto lol()
7     int aha = 3;
8     return [&aha] {
9         return aha; // { dg-warning "dereferencing pointer '.*' to within stale stack frame" }
10     };
11     /* TODO: may be worth special-casing the reporting of dangling
12        references from lambdas, to highlight the declaration, and maybe fix
13        the wording (it's a reference, not a pointer, for one thing).  */
16 int main()
18     auto lambda = lol();
19     std::cout << lambda() << std::endl;
20     return 0;