Red Hat Bugzilla – Bug 57774
libstdc++-devel-2.96-85 provides STL container std::map, size() does not properly increment via operator, only insert() works correctly.
Last modified: 2007-04-18 12:38:48 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.77 [en] (X11; U; Linux 2.4.6-pre1-xfs-4 i686)
Description of problem:
There are two means of inserting new elements into std::map, one via
literal insert(), the other via operator. In the latter case if an
element of key already exists, it merely updates the value and does not
change size(). If the element does not exist, it creates a new element and
increments size(). This fails and never increments to size beyond 1. It
should always update size() to match the number of keys present. Test case
was via std::map<std::string,std::string>, e.g., my_map["some_element"] =
"new value" (prior to this assert that key "some_element" cannot be found).
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Check a std::map size().
2. Verify that an element of key type (about to be inserted) does not
3. Use operator notation to add a new key and value pair.
4. Verify size() has incremented by 1.
5. Repeat with a new key; size() will never increment over 1, but should
reflect the total number of keys (use of iterators will prove the key and
value pairs do exist and that there is more than 1 element in the map).
Actual Results: size() never shows greater than 1 if inserts are done via
Expected Results: size() must always reflect the number of elements in the
Use of the literal operator insert() does successfully and correctly
increment size. If it is necessary to know the number of elements in the
map, operator cannot be used without introducing a false size().
NOTE: There is no bugzilla list for libstdc++-devel, it is necessary to
report it instead under libstdc++. Tested version is
libstdc++-devel-2.96-85, g++ 2.96. In addition to the bug fix,
libstdc++devel should be added as a package in bugzilla.
No code to reproduce, cannot tell if a bug in implementation or usage.
Please provide a test case.
If you have a testcase, please reopen.