title: Evil samples of subtly broken C++ code
body: <p>I need some samples of bad C++ code that will illustrate violation of good practices. I wanted to come up with my own examples, but I am having a hard time coming up with examples that are <em>not contrived, and where a trap is not immediately obvious</em> (it's harder than it seems).</p>
  
  <p>Examples would be something like:</p>
  
  <ol>
  <li>Not defining copy constructor for classes with <code>std::auto_ptr</code> members, and using <code>std::auto_ptr</code> members with forward-declared classes.</li>
  <li>Calling virtual functions from a constructor or a destructor (directly or indirectly).</li>
  <li>Overloading a template function.</li>
  <li>Circular references with <code>boost::shared_ptr</code>.</li>
  <li>Slicing.</li>
  <li>Throwing exceptions from C callbacks (directly or indirectly).</li>
  <li>Floating point comparison for equality.</li>
  <li>Exception safety of constructors with raw pointer members.</li>
  <li>Throwing from destructors.</li>
  <li>Integer overflow when compiled on different architectures (mismatch of <code>size_t</code> and <code>int</code>).</li>
  <li>Invalidating a container iterator.</li>
  </ol>
  
  <p>...or any other evil thing you can think of.</p>
  
  <p>I'd appreciate some pointers to existing resources, or a sample or two.</p>