summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2012-04-04 15:47:39 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2012-04-05 07:46:07 -0500
commit3f745dd4998f42e82fecadd4bcdd7e5662ad6b01 (patch)
treee6804e5e1d671938cffcc273c8d3a032d42b37c7 /src
parent493229c3892ab031cb46621f4de99715731d63db (diff)
downloadtalos-hostboot-3f745dd4998f42e82fecadd4bcdd7e5662ad6b01.tar.gz
talos-hostboot-3f745dd4998f42e82fecadd4bcdd7e5662ad6b01.zip
Fix broken map::operator[].
According to the STL documentation, 'insert' should do nothing if attempting to insert an item that already exists. This allows [] to be implemented as a form of insert(pair(key, data_T())). Our insert was actually updating the data portion of the map, which was causing operator[] to always erase the data portion of any lookup. Change-Id: I5b2ae1934dbd81d71df4b56d83e2f04f53f0e525 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/825 Tested-by: Jenkins Server Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com> Reviewed-by: Bradley W. Bishop <bradleyb@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/include/util/impl/stlmap.H1
-rw-r--r--src/usr/testcore/lib/stltest.H6
2 files changed, 6 insertions, 1 deletions
diff --git a/src/include/util/impl/stlmap.H b/src/include/util/impl/stlmap.H
index bed6674b7..599e1ed22 100644
--- a/src/include/util/impl/stlmap.H
+++ b/src/include/util/impl/stlmap.H
@@ -340,7 +340,6 @@ namespace Util
}
else
{
- reinterpret_cast<_Node*>(n)->data_T().second = x.second;
return make_pair(iterator(_TreeItr(&iv_tree, n)),
true);
}
diff --git a/src/usr/testcore/lib/stltest.H b/src/usr/testcore/lib/stltest.H
index b9a16d927..2c4efcb14 100644
--- a/src/usr/testcore/lib/stltest.H
+++ b/src/usr/testcore/lib/stltest.H
@@ -85,6 +85,12 @@ class STLTest : public CxxTest::TestSuite
mymap[v5] = v5;
mymap[v3] = v3;
+ if (v5.value() != mymap[v5].value()) // map::operator[] value
+ {
+ TS_FAIL("map::operator[] returned wrong value %d",
+ mymap[v5].value());
+ }
+
// test map::insert(v), map::insert(h,v), lower_bound()
mymap.insert(std::map<V,V>::value_type(v2,v2)); //map::insert(v);
OpenPOWER on IntegriCloud