mapnik/mapnik — Issue #964: Copy assignment operators without check against self-assignment
Author: elfring
Created: 2011-11-24 18:00:39+00:00
State: open

I have found a few source files for classes which contain custom copy assignment operators.

Examples:
- [layer.cpp](https://github.com/mapnik/mapnik/blob/f1fb0c1939c6c8d264ae9df4be962ff1c6c07a3c/src/layer.cpp#L65)
- [projection.cpp](https://github.com/mapnik/mapnik/blob/f1fb0c1939c6c8d264ae9df4be962ff1c6c07a3c/src/projection.cpp#L53)
- [stroke.cpp](https://github.com/mapnik/mapnik/blob/f1fb0c1939c6c8d264ae9df4be962ff1c6c07a3c/src/stroke.cpp#L80)

I wonder why checks against self-assignment were omitted.

See also:
- [CERT C++ Secure Coding Standard](https://www.securecoding.cert.org/confluence/display/cplusplus/MEM42-CPP.+Ensure+that+copy+assignment+operators+do+not+damage+an+object+that+is+copied+to+itself "Ensure that copy assignment operators do not damage an object that is copied to itself.")
- [C++ frequently answered questions](http://dietmar-kuehl.de/mirror/c++-faq/assignment-operators.html#faq-12.3 "OK, OK, already; I'll handle self-assignment. How do I do it?")