[LifetimeSafety] Detect invalidation of containers as fields
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
https://godbolt.org/z/Ye7o9xqff
```cpp
struct InvalidateMemberFields {
InvalidateMemberFields();
void invalidateField() {
auto it = container.begin();
container.push_back("1");
(void)*it;
}
void invalidateFieldRef() {
auto it = contiainerRef.begin();
contiainerRef.push_back("1");
(void)*it;
}
private:
std::vector container;
std::vector& contiainerRef;
};
```
Contributor guide
Research direction
Start with the linked Compiler Explorer reproducer and the LifetimeSafety implementation in LLVM. Check how invalidation is handled for the direct std::vector field and the referenced container, then establish tests showing that dereferencing the iterator after push_back is detected for both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100