[Bug c++/90647] Warn on returning a lambda with captured local variables
egallager at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Nov 30 04:48:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90647
--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Antony Polukhin from comment #0)
> Consider the example:
>
> auto test(int s) {
> return [&s] { return s; };
> }
>
>
> `s` is a local variable, so we return a lambda that has a dangling reference.
>
> It would be nice to have a warning for such cases.
Under -Wreturn-local-addr, or a new flag?
More information about the Gcc-bugs
mailing list