steakhal wrote:
According to claude, this is a more ergonomic reproducer:
```c++
// An object passed by value to a function that is not inlined is constructed
// directly into the parameter region of the callee, which lives in a stack
// frame that is never entered. That frame is not on the stack while the
// constructor body runs, but the argument still outlives the call, so nothing
// dangles here.
struct Chained {
Chained &self() [[clang::lifetimebound]] { return *this; }
// The second call is what matters: the first one records `self()`'s return
// value as bound to the parameter region, the second one looks it up again.
Chained() {
self();
self(); // no-warning
}
};
void takes_by_value(Chained arg);
void no_dangling_by_value_argument() {
takes_by_value(Chained()); // no-warning
}
```
https://github.com/llvm/llvm-project/pull/213779
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits