#1521: Piraha smart_ptr can't handle self assignment -----------------------+---------------------------------------------------- Reporter: eschnett | Owner: sbrandt Type: defect | Status: review Priority: major | Milestone: Component: Cactus | Version: development version Resolution: | Keywords: -----------------------+----------------------------------------------------
Comment (by eschnett):
The patch is wrong; you need to skip both the clean() and inc() calls.
I think that "if (this==&s) return *this;" as the first line of operator= should work.
- if this and &s point to the same object, then the assignment operator is a no-op, so nothing needs to be done. - if the pointers are different, but their guts are the same, then dec/inc should not matter since there are at least two pointers.