This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[PATCH] : PR libstdc++ 3349
- To: gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Subject: [PATCH] : PR libstdc++ 3349
- From: Sylvain Pion <Sylvain dot Pion at sophia dot inria dot fr>
- Date: Fri, 17 Aug 2001 00:49:00 +0200
- Cc: pedwards at disaster dot jaj dot com, Sylvain Pion <Sylvain dot Pion at sophia dot inria dot fr>
Hi,
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), and I
couldn't find where this file was before, so couldn't "cvs annotate" to tell
why exactly this change was made. Someone who knows should probably double
check. Here's a test-case for the test-suite :
void test()
{
typedef std::map<int, int> Map;
Map M;
Map::iterator hint;
hint = M.insert(Map::value_type(7, 0)).first;
M.insert(hint, Map::value_type(8, 1));
if (M.find(7) == M.end())
abort();
}
--
Sylvain
ChangeLog
2001-08-17 Sylvain Pion <Sylvain.Pion@sophia.inria.fr>
PR libstdc++/3349
* include/bits/stl_tree.h (insert_unique): undo last change.
Index: include/bits/stl_tree.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_tree.h,v
retrieving revision 1.2.6.2
diff -u -c -3 -p -r1.2.6.2 stl_tree.h
*** stl_tree.h 2001/06/27 17:12:28 1.2.6.2
--- stl_tree.h 2001/08/16 22:38:08
*************** _Rb_tree<_Key, _Val, _KeyOfValue, _Compa
*** 920,926 ****
{
if (__position._M_node == _M_header->_M_left) { // begin()
if (size() > 0 &&
! _M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__v)))
return _M_insert(__position._M_node, __position._M_node, __v);
// first argument just needs to be non-null
else
--- 920,926 ----
{
if (__position._M_node == _M_header->_M_left) { // begin()
if (size() > 0 &&
! _M_key_compare(_KeyOfValue()(__v), _S_key(__position._M_node)))
return _M_insert(__position._M_node, __position._M_node, __v);
// first argument just needs to be non-null
else