[LifetimeSafety] False negative on assignment from Owner to Pointer
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
The analysis misses this GSL Pointer assignment case:
```cpp
struct [[gsl::Owner]] Owner {
Owner();
};
struct [[gsl::Pointer]] View {
View();
View &operator=(const Owner &o [[clang::lifetimebound]]);
void use() const;
};
void f() {
View v;
{
Owner o;
v = o;
} // o is destroyed here!
v.use(); // no warning
}
```
Expected: warn that o does not live long enough.
https://godbolt.org/z/EMT4WWrnc
Contributor guide
Research direction
Start by reproducing the GSL Owner-to-Pointer assignment example in the linked Godbolt case and inspect Clang's LifetimeSafety analysis for lifetimebound assignment handling. The work is done when this case diagnoses that o does not live long enough before v.use(), while the analysis remains correct for related assignments.
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
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100