Returning address of variable copied into lambda produces spurious warning. #17748
Labels
bugzilla
Issues migrated from bugzilla
c++11
clang:diagnostics
New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Extended Description
Given the following sample code:
int main()
{
int i;
auto f = =mutable->int*
{
return &i;
};
}
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.
The text was updated successfully, but these errors were encountered: