[LifetimeSafety] Assertion failure on lifetime_capture_by in a member function
Open
clang:temporal-safety
crash-on-valid
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
`-Wlifetime-safety` hits an assertion when `[[clang::lifetime_capture_by()]]` names another parameter of a member function:
https://godbolt.org/z/rzqEjvGPf
```c++
// crashes
struct S {
void cap(int *p [[clang::lifetime_capture_by(c)]], int *&c);
};
void use() { S s; int i; int *c; s.cap(&i, c); }
```
```
Assertion `Index < Length && "Invalid index!"' failed.
```
The same signature as a free function or as a static member function does not crash:
```c++
// does not crash
void cap(int *p [[clang::lifetime_capture_by(c)]], int *&c);
void use() { int i; int *c; cap(&i, c); }
```
Contributor guide
Assessment
This issue has not been assessed yet.