llvm-project
llvm-project copied to clipboard
[LifetimeSafety] False negative on assignment from Owner to Pointer
The analysis misses this GSL Pointer assignment case:
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
@llvm/issue-subscribers-clang-temporal-safety
Author: NeKon69
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
@usx95 Misclick?
oops. Yes.