This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Red-black trees was Re: [PATCH] : PR libstdc++ 3349


On Fri, Aug 17, 2001 at 12:49:00AM +0200, Sylvain Pion wrote:
> This trivial patch fixes PR 3349, a 2.95 regression, concerning a bug in
> std::map.insert(hint, value).  It just reverts the code to what was in old
> versions, presumably before changes made by John Potter in 1999.  I couldn't
> access the mail archives of libstdc++ from that time (broken links),

The archives are still corrupted and waiting for someone with sysadmin
authority onsite to reload from backups.  This will not happen anytime
soon (it's a time-consuming task and they are busy).  I hunted around; it
looks like there are 4 messages in the thread, of which 3 have been lost.

The remaining one (seems to be #3) is appended below.  It's HTML because
I pulled it from the web archives.  It may take me a couple of attempts
to post it to the list (HTML filters in place).


> and I
> couldn't find where this file was before, so couldn't "cvs annotate" to tell
> why exactly this change was made.

It's in the same place, but the CVS history was destroyed during the
official merge into the GCC repository, 4 months after the change happened.
I don't know whether the old repository is still around... *checks* ...maybe.
I'll try pulling a copy of it down and looking through it.

But from the contents of the mail message below, I suspect the CVS log
will only show "Fix."


> Someone who knows should probably double
> check.  Here's a test-case for the test-suite :

I have a slightly modified version of this test in my local tree now (with
your name on it).  I can check it in now or at the same time we fix this.
Benjamin?

As for the patch itself... I haven't looked at RB trees since I was
an undergraduate.  If there's anyone here familiar enough with the code
offhand, please comment.  Otherwise I'll re-acquaint myself after I finish
changing apartments.

Phil



<!--X-Subject-Header-Begin-->
<h1>re: insert_unique with hint bug</h1>
<!--X-Subject-Header-End-->
<UL>
<LI><em>To</em>: Benjamin Kosnik &lt;bkoz@cygnus.com&gt;</LI>
<LI><em>Subject</em>: re: insert_unique with hint bug</LI>
<LI><em>From</em>: John Potter &lt;jpotter@eagle.lhup.edu&gt;</LI>
<LI><em>Date</em>: Fri, 25 Jun 1999 11:51:09 -0400 (EDT)</LI>
<LI><em>cc</em>: libstdc++@sourceware.cygnus.com</LI>
</UL>
<HR>
<PRE>

Just guessing from the line numbers, you are making the change to
insert_unique which would break it by allowing duplicates at the
beginning of tree.  The second part is for insert_equal which
would fix it allowing insertion of a duplicate at the beginning
of tree.

Sorry for working with an old source and not being sure.

John

On Thu, 24 Jun 1999, Benjamin Kosnik wrote:

&gt; This looks like a bug that is still present in SGI STL 3.20, and in
&gt; current v-3 snapshots. Here's an updated version of your patch, which
&gt; could also be applied to the egcs-1.1 (and later) sources.
&gt; 
&gt; If it's ok with you, and nobody else has any objections, I'll check it in
&gt; later today.
&gt; 
&gt; -benjamin
&gt; 
&gt; 
&gt; 1999-06-24 Benjamin Kosnik &lt;bkoz@tintin.cygnus.com&gt;
&gt;            John Potter  &lt;jpotter@eagle.lhup.edu&gt;
&gt; 
&gt; 	* stl/bits/stl_tree.h (insert_equal): Fix.
&gt; 
&gt; 
&gt; Index: stl_tree.h
&gt; ===================================================================
&gt; RCS file: /cvs/libstdc++/libstdc++/stl/bits/stl_tree.h,v
&gt; retrieving revision 1.9
&gt; diff -c -p -r1.9 stl_tree.h
&gt; *** stl_tree.h	1999/02/10 01:00:36	1.9
&gt; --- stl_tree.h	1999/06/24 19:33:46
&gt; *************** _Rb_tree&lt;_Key, _Val, _KeyOfValue, _Compa
&gt; *** 937,943 ****
&gt;   {
&gt;     if (__position._M_node == _M_header-&gt;_M_left) { // begin()
&gt;       if (size() &gt; 0 &amp;&amp; 
&gt; !         _M_key_compare(_KeyOfValue()(__v), _S_key(__position._M_node)))
&gt;         return _M_insert(__position._M_node, __position._M_node, __v);
&gt;       // first argument just needs to be non-null 
&gt;       else
&gt; --- 937,943 ----
&gt;   {
&gt;     if (__position._M_node == _M_header-&gt;_M_left) { // begin()
&gt;       if (size() &gt; 0 &amp;&amp; 
&gt; !        ! _M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__v)))
&gt;         return _M_insert(__position._M_node, __position._M_node, __v);
&gt;       // first argument just needs to be non-null 
&gt;       else
&gt; *************** _Rb_tree&lt;_Key,_Val,_KeyOfValue,_Compare,
&gt; *** 970,976 ****
&gt;   {
&gt;     if (__position._M_node == _M_header-&gt;_M_left) { // begin()
&gt;       if (size() &gt; 0 &amp;&amp; 
&gt; !         _M_key_compare(_KeyOfValue()(__v), _S_key(__position._M_node)))
&gt;         return _M_insert(__position._M_node, __position._M_node, __v);
&gt;       // first argument just needs to be non-null 
&gt;       else
&gt; --- 970,976 ----
&gt;   {
&gt;     if (__position._M_node == _M_header-&gt;_M_left) { // begin()
&gt;       if (size() &gt; 0 &amp;&amp; 
&gt; !        ! _M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__v)))
&gt;         return _M_insert(__position._M_node, __position._M_node, __v);
&gt;       // first argument just needs to be non-null 
&gt;       else
&gt; 
&gt; 

</PRE>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]