[clang] [WIP][clang]: Implement a conditional lifetimebound_if builtin. (PR #125520)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 23 23:27:56 PST 2025
hokein wrote:
> A moved from object could be reinitalized:
>
> ```
> void test() {
> std::vector<std::string_view> abc;
> std::string b;
> add(abc, std::move(b));
> b = std::string(); // now b can be used again.
> }
> ```
>
> That being said, maybe this is rare enough that we could have an opt-in warning. But we definitely cannot have something that is on by default.
I think we are primarily concerned with pointers or references to a moved-from object. When the moved-from object is reinitialized, using a pointer to it can be very tricky and is likely undefined behavior, https://godbolt.org/z/Wh5vKe8z6
https://github.com/llvm/llvm-project/pull/125520
More information about the cfe-commits
mailing list