[PATCH] D155776: [NFC] Add checks for self-assignment.
Tom Honermann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 20 08:10:51 PDT 2023
tahonermann added a comment.
Hmm, it seems exceptionally unlikely for a move assignment operator to be invoked on an object with itself as the source argument. That would require an explicit use of `std::move()` as in:
Value x = ...;
x = std::move(x);
Rather than protecting against that and making it a no-opt, I think we would want to be informed of code that manages to do so because it is probably not intended. We could instead `assert(this !=RHS)`, but I'm not sure that is warranted either.
I'm assuming this patch was made in response to a static analysis report. If so, I suggest we follow up with the static analysis vendor.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155776/new/
https://reviews.llvm.org/D155776
More information about the cfe-commits
mailing list