[llvm-bugs] [Bug 52136] New: [coroutine] undefined behavior when nested lambda coroutine captures automatic variables by reference

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 11 07:02:40 PDT 2021


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

            Bug ID: 52136
           Summary: [coroutine] undefined behavior when nested lambda
                    coroutine captures automatic variables by reference
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bhalevy at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Reproducer: https://godbolt.org/z/3d37ME161
Since clang 12.0.0 through to current trunk.

Coroutine foo instantiates a coroutine lambda.

When references to automatic variable are passed to the lambda coroutine as
arguments, all is well.

However, when the lambda captures the local variables by reference they seem to
go out of scope and referring to them in the lambda results in undefined
behavior.

-- 
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/20211011/45ad2201/attachment.html>


More information about the llvm-bugs mailing list