llvm / llvm/llvm-project

[LifetimeSafety] False-positive invalidation with lambda capturing a container

Open
#186,996 2 comments 0 reactions 0 assignees View on GitHub
clang:temporal-safety false-positive
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.