[[clang::lifetimebound]] triggers a spurious Wdangling-assignment
Open
clang:temporal-safety
false-positive
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Observed this with `ABSL_CHECK_OK` after adding auto-suggested `lifetimebound` annotations to `AsStatus()`, but a simplified example is:
```c++
const int* Ptr(const int& x [[clang::lifetimebound]]) {
return &x;
}
int main() {
for (const int* p; p = Ptr(42), p != nullptr; )
// ^^^ warning: object backing the pointer 'p' will be destroyed at the end of the full-expression [-Wdangling-assignment]
break;
}
```
https://godbolt.org/z/4zr9szjoq
Contributor guide
Assessment
This issue has not been assessed yet.