[LifetimeSafety] False-positive invalidation with lambda capturing a container
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
```cpp
#include
#include
void foo() {
std::vector 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.
Contributor guide
Research direction
Start with the C++ reproducer and the LifetimeSafety invalidation analysis described in the issue. Trace how the lambda's reference to v is treated after v.push_back(0); done means interior invalidations are represented granularly so the subsequent print() is not falsely rejected, with regression coverage for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100