[llvm-bugs] [Bug 38878] New: Enhance "returning address of local var" checker

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Sep 9 09:57:18 PDT 2018


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

            Bug ID: 38878
           Summary: Enhance "returning address of local var" checker
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

struct S&& po() {
    struct S tmp;
    return std::move(tmp);
}

No warning from Clang.

GCC warns:
<source>: In function 'S&& po()':
<source>:14:23: warning: function returns address of local variable
[-Wreturn-local-addr]
14 |     return std::move(tmp);
   |                       ^
<source>:13:14: note: declared here
13 |     struct S tmp;

-- 
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/20180909/31642670/attachment.html>


More information about the llvm-bugs mailing list