[LifetimeSafety] provide more details on lifetimebound violation
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
```cpp
#include
struct S
{
S(const std::vector& v); // missing annotation
};
S f2(const std::vector& v [[clang::lifetimebound]])
{
return {v}; // actual violation location
}
S f1(const std::vector& v [[clang::lifetimebound]])
{
return f2(v);
}
```
```
:8:34: warning: could not verify that the return value can be lifetime bound to 'v' [-Wlifetime-safety-lifetimebound-violation]
8 | S f2(const std::vector& v [[clang::lifetimebound]])
| ^~~~~~~~~~~~~~~~~~~~
```
https://godbolt.org/z/Wex6xaW1n
Contributor guide
Research direction
Start by reproducing the warning with the C++ example and compiler flag shown in the issue, using the linked Godbolt case as the reference. Trace the lifetimebound diagnostic from the reported location in f2; done means the warning provides more useful details about the missing annotation or actual violation while preserving the diagnostic's correctness.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100