llvm / llvm/llvm-project

[LifetimeSafety] Consider flowing origins through reinterpret_cast

Open
#196,834 5 comments 0 reactions 0 assignees View on GitHub
clang:temporal-safety
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```cpp
const int *bad(const int &x [[clang::lifetimebound]]) { // could not verify that the return value can be lifetime bound to 'x'
return (const int *)reinterpret_cast(&x); // clearly escapes
}
```

https://godbolt.org/z/nfqha7az6

Theoretically, we might need to tell the analyzer to assume it escapes regardless.

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.