Boost C++ Libraries: Ticket #2532: ptr_set<T>::erase(const T&) does not update the tree https://svn.boost.org/trac10/ticket/2532 <p> Hi </p> <p> In some cases ptr_set&lt;T&gt;::erase(const T&amp;) deletes the object as expected but does not remove the node in the tree. </p> <p> =&gt; the tree is left with a dangling pointer </p> <p> Consider the following example: </p> <pre class="wiki">#include &lt;boost/ptr_container/ptr_set.hpp&gt; #include &lt;boost/foreach.hpp&gt; #include &lt;iostream&gt; using namespace std; class Int { public: Int (int v) : val (v) { cout &lt;&lt; "\t\tnew: " &lt;&lt; this &lt;&lt; " -&gt; " &lt;&lt; val &lt;&lt; endl; } ~Int () { cout &lt;&lt; "\t\tdelete: " &lt;&lt; this &lt;&lt; " -&gt; " &lt;&lt; val &lt;&lt; endl; } bool operator&lt; (const Int&amp; b) const { return val &lt; b.val; } int val; }; int main() { boost::ptr_set&lt;Int&gt; s; s.insert (new Int (3)); s.insert (new Int (1)); s.insert (new Int (2)); BOOST_FOREACH (Int&amp; i, s) { cout &lt;&lt; &amp;i &lt;&lt; " -&gt; " &lt;&lt; i.val &lt;&lt; endl; } cout &lt;&lt; endl; s.erase (Int(2)); BOOST_FOREACH (Int&amp; i, s) { cout &lt;&lt; &amp;i &lt;&lt; " -&gt; " &lt;&lt; i.val &lt;&lt; endl; } return 0; } </pre><p> --&gt; output </p> <pre class="wiki"> new: 0x9759008 -&gt; 3 new: 0x9759030 -&gt; 1 new: 0x9759058 -&gt; 2 0x9759030 -&gt; 1 0x9759058 -&gt; 2 0x9759008 -&gt; 3 new: 0xbfe387ac -&gt; 2 delete: 0x9759058 -&gt; 2 &lt;---- object deleted delete: 0xbfe387ac -&gt; 2 0x9759030 -&gt; 1 0x9759058 -&gt; 0 &lt;---- dangling node/pointer !!! 0x9759008 -&gt; 3 delete: 0x9759030 -&gt; 1 delete: 0x9759058 -&gt; 0 &lt;---- object deleted again !!! delete: 0x9759008 -&gt; 3 </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2532 Trac 1.4.3 Thorsten Ottosen Tue, 17 Feb 2009 22:50:38 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2532#comment:1 https://svn.boost.org/trac10/ticket/2532#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket