Bug 57774 - libstdc++-devel-2.96-85 provides STL container std::map, size() does not properly increment via operator[], only insert() works correctly.
libstdc++-devel-2.96-85 provides STL container std::map, size() does not prop...
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: libstdc++ (Show other bugs)
7.1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-12-21 16:28 EST by D. Stimits
Modified: 2007-04-18 12:38 EDT (History)
1 user (show)

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


Attachments (Terms of Use)

  None (edit)
Description D. Stimits 2001-12-21 16:28:46 EST
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:
Always

Steps to Reproduce:
1. Check a std::map size().
2. Verify that an element of key type (about to be inserted) does not
exist.
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
operator[].

Expected Results:  size() must always reflect the number of elements in the
std::map.

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 11:27:05 EDT
No code to reproduce, cannot tell if a bug in implementation or usage.

Please provide a test case.

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

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