Bug 57774 - libstdc++-devel-2.96-85 provides STL container std::map, size() does not properly increment via operator[], only insert() works correctly.
Summary: libstdc++-devel-2.96-85 provides STL container std::map, size() does not prop...
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: libstdc++   
(Show other bugs)
Version: 7.1
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2001-12-21 21:28 UTC by D. Stimits
Modified: 2007-04-18 16:38 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-11-24 14:25:36 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description D. Stimits 2001-12-21 21:28:46 UTC
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):

How reproducible:

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

Additional info:

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.

Comment 1 Benjamin Kosnik 2004-10-01 15:27:05 UTC
No code to reproduce, cannot tell if a bug in implementation or usage.

Please provide a test case.


Comment 2 Jakub Jelinek 2004-11-24 14:25:36 UTC
If you have a testcase, please reopen.

Note You need to log in before you can comment on or make changes to this bug.