From 3f745dd4998f42e82fecadd4bcdd7e5662ad6b01 Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Wed, 4 Apr 2012 15:47:39 -0500 Subject: 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 Reviewed-by: Bradley W. Bishop Reviewed-by: A. Patrick Williams III --- src/usr/testcore/lib/stltest.H | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/usr/testcore') 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::value_type(v2,v2)); //map::insert(v); -- cgit v1.2.1