llvm / llvm/llvm-project

[LifetimeSafety] False-positive due to assignments involving std::tie

Open
#181,196 1 comment 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

https://godbolt.org/z/q6ToGh779
```cpp
#include
#include

int& reproduce(int Key) {
std::map Cache;
std::map::iterator It = Cache.begin();
bool New;
std::tie(It, New) = Cache.try_emplace(Key);

return It->second;
}
```

`std::tie` on LHS should KILL the iterator `It` value and therefore it shouldn't be considered alive at the point of invalidation.

Contributor guide

Open the contributing guide

Research direction

Start with the Godbolt reproducer in the issue and inspect the LifetimeSafety analysis handling of assignments to std::tie. Confirm how the left-hand-side assignment affects the iterator's lifetime state, then add regression coverage showing that this example no longer produces a false positive.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.