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: unassignedb...@nondot.org
          Reporter: josephcsi...@gmail.com
                CC: htmldevelo...@gmail.com, llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to