hokein wrote:

> The lifetime safety analysis was previously generating false positives by 
> warning about use-after-lifetime when the original variable was destroyed 
> after being moved. This change prevents those false positives by tracking 
> moved declarations and exempting them from loan expiration checks.

Just a note.

While this fixes false positives, it introduces false negatives. The pointer is 
not always valid after the owner object is moved, an use-after-free example 
(when the string uses short string optimization) https://godbolt.org/z/eP7PbaMEn

```
int main() {
    std::string_view s;
    std::string b;
    {
      std::string a = "12345";  // small literal, stored in the string object, 
rather than the heap.
      s = a;
      b = std::move(a);
    }
    std::cout << s << "\n"; // oops, s refers to a dangling object.

}
```

https://github.com/llvm/llvm-project/pull/170007
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to