Returning a lambda with local reference

In the same spirit of core.StackAddressEscape, there is an instance of problem involving a lambda that could be detected:

std::function<void ()> make_func()
{
    QString msg("local variable invalid outside of make_func");
    return [&] () { qDebug() << "lambda invalid" << msg; };
}

The function returns a lambda holding a reference to a variable on the stack. Invoking the lambda is likely to trigger SIGSEGV. Currently, the check returns this:

scan-build: No bugs found.

I just thought it would be useful to share this case.

Cheers,

Francis