Skip to content

Commit

Permalink
assert on self move assignment
Browse files Browse the repository at this point in the history
Test Plan: ran tests in dbg

Reviewed By: tudorb@fb.com

FB internal diff: D696964
  • Loading branch information
philippv authored and jdelong committed Mar 19, 2013
1 parent ce80e19 commit 2a80dba
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions folly/FBString.h
Expand Up @@ -1042,8 +1042,8 @@ class basic_fbstring {
~basic_fbstring() {
}

basic_fbstring& operator=(const basic_fbstring & lhs) {
if (&lhs == this) {
basic_fbstring& operator=(const basic_fbstring& lhs) {
if (FBSTRING_UNLIKELY(&lhs == this)) {
return *this;
}
auto const oldSize = size();
Expand All @@ -1066,6 +1066,8 @@ class basic_fbstring {

// Move assignment
basic_fbstring& operator=(basic_fbstring&& goner) {
// Self move assignment is illegal, see 17.6.4.9 for the explanation
assert(&goner != this);
// No need of this anymore
this->~basic_fbstring();
// Move the goner into this
Expand Down

0 comments on commit 2a80dba

Please sign in to comment.