[llvm-bugs] [Bug 47702] auto function return the reference of a local variable not the value

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 1 12:25:47 PDT 2020


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

David Blaikie <dblaikie at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
                 CC|                            |dblaikie at gmail.com
             Status|NEW                         |RESOLVED

--- Comment #1 from David Blaikie <dblaikie at gmail.com> ---
This program has undefined behavior.

The lambda captures the value by reference, but the value goes out of scope at
the end of 'func', before the lambda is called. So the lambda has a dangling
reference.

-- 
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/20201001/d49c539d/attachment.html>


More information about the llvm-bugs mailing list