Got such a problem - I do not know how to fix it. There is the following code:
Foo& operator+(const Foo& other) { Foo result(this._field + other._field); return result; } In the class there is a pointer field, respectively, in the constructor it is initialized through new, in the destructor it is deleted through delete. And here's the problem: upon the completion of the operator’s work, the destructor is called for result! well, it is clear that in a place like Foo foo = A + B; (where A and B are also clear to Foo) the destructor will be called again. I get 2 release.