[LLVMbugs] [Bug 17374] New: Returning address of variable copied into lambda produces spurious warning.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Sep 25 17:04:39 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=17374

            Bug ID: 17374
           Summary: Returning address of variable copied into lambda
                    produces spurious warning.
           Product: clang
           Version: 3.2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: surfintheusa at yahoo.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Given the following sample code:

int main()
{
    int i;
    auto f = [=]()mutable->int*
    {
            return &i;
    };

    return 0;
}

The compiler reports "address of stack memory associated with local variable
'i' returned" for the 'i' in the lambda. That warning would be legitimate for a
plain function but not for a lambda.

Note that this bug appears similar to bug #16548 but it is not the same. Here,
the variable is captured by value rather than by 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/20130926/57014b54/attachment.html>


More information about the llvm-bugs mailing list