llvm-project
llvm-project copied to clipboard
[LifetimeSafety] False-positive invalidation with lambda capturing a container
#include <iostream>
#include <vector>
void foo() {
std::vector<int> v;
auto print = [&]() { std::cout << v.size(); };
v.push_back(0);
print();
}
This is because we currently consider even the reference to v (which is captured by the lambda) as invalidated after the push_back. We need granular paths to represent interior invalidations.
@llvm/issue-subscribers-clang-temporal-safety
Author: Utkarsh Saxena (usx95)
```cpp
#include <iostream>
#include <vector>
void foo() { std::vector<int> v; auto print = & { std::cout << v.size(); }; v.push_back(0); print(); }
This is because we currently consider even the reference to `v` (which is captured by the lambda) as invalidated after the `push_back`. We need granular paths to represent interior invalidations.
</details>
Hey @usx95 , I am interested in this issue, can u assign this to me ?
Gentle ping @usx95 for assigning this to me.