https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90647

            Bug ID: 90647
           Summary: Warn on returning a lambda with captured local
                    variables
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antoshkka at gmail dot com
  Target Milestone: ---

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.

Reply via email to