Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correctly implement StringView's operator= (facebook#160)
Summary: Prior to this fix, StringView has an implicitly defined operator=. However StringView conditionally holds onto a Handle. If you invoke the implicit operator=, it would copy the bits over which would result in skipping Handle's ctor and dtor. This then trips the Handle count book-keeping in GCScope. It's hard to stumble upon this because if the rhs of the operator= is a StringView whose Handle is in the same GCScope, the missing dtor and missing ctor would happen to balance so the count would remain the same. However if you assign a StringView from a *different* GCScope, you can trip the Handle count assertion. Implement operator= properly in debug mode and add a test for it. Also add a test for move ctor and assignment; this doesn't fail today because the copy-ctor and copy-assignment suppresses implicit move ctor/assignment. Pull Request resolved: facebook#160 Reviewed By: kodafb Differential Revision: D18823837 Pulled By: mhorowitz fbshipit-source-id: 761f812369dd521d9ebfd5aab7603928dc45b8c4
- Loading branch information