Comment Re:Oh yeah (Score 3, Interesting) 102
I ran into an issue not too long ago with a custom stateless unique_ptr deleter, when one of the interfaces I derived from (in a third party library) was placed ahead of my own interface class in the derived class declaration. My own interface had a virtual destructor, while the library interface did not (which I didn't notice at the time). The deleter was blowing up, and only after I noticed it was off by one was I able to figure out why it was happening: the code was unable to cast properly, so ended up at the wrong address in memory because of the v-table layout.
This was fixed by switching the order of the two interfaces which corrected the in-memory layout so it would work. Alternatively, a shared_ptr would have worked as well, albeit with unnecessary extra overhead in that case. It's not exactly a new gotcha, but the unique_ptr + deleter put enough of a new wrinkle on it to throw me off for a while.
C++ gives you a lot of power and speed, but it definitely comes at a price in terms of issues like this. No one who knows C++ would seriously claim the language doesn't have sharp edges that still trip up full-time professional C++ programmers. Still, I love the power and speed the language gives me, while still affording me protection from the sort of mistakes that crop up in C code. For me, C++11 has been an amazing win so far in terms of overall productivity and code safety.