[llvm-bugs] [Bug 51057] New: False negative -Wreturn-stack-address when returning std::function instead of auto

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jul 11 19:33:04 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51057

            Bug ID: 51057
           Summary: False negative -Wreturn-stack-address when returning
                    std::function instead of auto
           Product: new-bugs
           Version: 12.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: josephcsible at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Consider this C++ code:

#include <functional>

struct Foo {
    void bar();
};

auto f() {
    Foo foo;
    return [&]() {
        foo.bar();
    };
}

It results in a -Wreturn-stack-address warning, as it should. But if you
replace "auto f()" with "std::function<void()> f()", then the warning goes
away, even though the problem is still there.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210712/a1de3139/attachment.html>


More information about the llvm-bugs mailing list