llvm / llvm/llvm-project

Make it clearer how a loan ended up being used after it is destroyed

Open
#177,986 5 comments 0 reactions 1 assignee Claimed by @suoyuan666 View on GitHub
clang:temporal-safety
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The idea for improvement is to highlight all the expressions/statements responsible for loan propagation of the expired loan to an origin which is used after the loan expires.
```cpp
#include
#include
#include

void foo() {
std::string_view f;
{
std::string str = "small scoped string";
std::string_view a, b, c, d, e;
a = str; // Ok. error: object whose reference is captured does not live long enough.
// TODO: add note: 'a' aliases 'str'
b = a;
c = a; // TODO: add note: 'c' aliases 'a'
d = c; // TODO: add note: 'd' aliases 'c'
e = d;
f = d; // TODO: add note: 'f' aliases 'd'
}
std::cout << f;
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.