invoking copy constructor inside other constructor-Collection of common programming errors
I don’t know what standard actually says about it, but “placement new” is designed to be used with a memory block that was just allocated and containts junk. Using it like you do leads to memory leaks, because new std::string instance is constructed, but original instance wasn’t destroyed. You can check you program with “valgrind” and you will see that block of memory was lost.
Originally posted 2013-11-09 23:21:35.