LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 17374 - Returning address of variable copied into lambda produces spurious warning.
Summary: Returning address of variable copied into lambda produces spurious warning.
Status: NEW
Alias: None
Product: clang
Classification: Unclassified
Component: C++11 (show other bugs)
Version: 3.2
Hardware: All All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-25 19:04 PDT by surfintheusa
Modified: 2013-09-25 19:04 PDT (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description surfintheusa 2013-09-25 19:04:39 PDT
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.