[LifetimeSafety] Consider flowing origins through reinterpret_cast
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<uintptr_t>(&x); // clearly escapes
}
https://godbolt.org/z/nfqha7az6
Theoretically, we might need to tell the analyzer to assume it escapes regardless.
@llvm/issue-subscribers-clang-frontend
Author: NeKon69
https://godbolt.org/z/3Ghb1WjTq
Theoretically, we might need to tell the analyzer to assume it escapes regardless.
False-positive or false-negative? Check again pls.
Looks like clang trunk on godbolt didn't get rebuilt yet with this commit (which is weird, I thought trunk versions of compilers get rebuilt every day at 0:00 UTC..). And yes, it is a false positive, sorry for all the hassle.
EDIT: clang is rebuilt now and the warnings shows up.
@llvm/issue-subscribers-clang-temporal-safety
Author: NeKon69
https://godbolt.org/z/nfqha7az6
Theoretically, we might need to tell the analyzer to assume it escapes regardless.
We could consider flowing the origins optimistically through reinterpret_cast if the argument has an origin!
(There is no systematic way to support this in a lifetime model and should be considered a lower priority atm).