BusyBox Bug and Patch Tracking
BusyBox
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0000301 [uClibc++] Other major always 06-17-05 06:13 08-02-05 20:13
Reporter asierllano View Status public  
Assigned To gkajmowi
Priority normal Resolution fixed  
Status closed   Product Version 0.1.9
Summary 0000301: map::lower_bound, map::upper_bound without existing key
Description The behaviour of map::lower_bound and map::upper_bound is not correct, when they are used with a non existing key:
If you make a test:

map<string, int> m;
m["k"] = 3;
if (m.lower_bound("a") == m.end()) {
    cout << "This should not happen";
}

But it happens, becuase upper_bound and lower_bound uses find instead of ifind.
And it does also happen because we suppose that upper_bound is always the next one of the one returned, but it can be the next one, or not depending if it existed already.

For more information about the behaviour it should have:
http://www.sgi.com/tech/stl/SortedAssociativeContainer.html [^]
Additional Information I've provided two patches with different approaches to solve this problem.

PATCH 1. The not intrusive patch.
Just used ifind instead of find in all the map::lower_bound map::upper_bound. Minimum lines to solve the problem.

PATCH 2. ifind is a non standard name to lower_bound.
Due to the fact the the non-standard function ifind performs the same operation than lower_bound do, I think it should be renamed to be lower_bound, and every function that uses ifind should use lower_bound. This way you avoid introducing a non standard concept of lower_bound.

I prefer the second one, but you could use the first one if you think the second one is too intrusive.
Attached Files  uclibcxx-0.1.9-map_bound-1.patch [^] (1,893 bytes) 06-17-05 06:13
 uclibcxx-0.1.9-map_bound-2.patch [^] (8,214 bytes) 06-17-05 06:14

- Relationships

- Notes
(0000258)
gkajmowi
07-02-05 12:21

Used solution 1. Solution 2 caused multimap code to stop working and fail test suite.
 

- Issue History
Date Modified Username Field Change
06-17-05 06:13 asierllano New Issue
06-17-05 06:13 asierllano File Added: uclibcxx-0.1.9-map_bound-1.patch
06-17-05 06:14 asierllano File Added: uclibcxx-0.1.9-map_bound-2.patch
06-27-05 08:35 asierllano Issue Monitored: asierllano
07-02-05 12:21 gkajmowi Status assigned => resolved
07-02-05 12:21 gkajmowi Fixed in Version  => 0.1.12
07-02-05 12:21 gkajmowi Resolution open => fixed
07-02-05 12:21 gkajmowi Note Added: 0000258
08-02-05 20:13 andersen Status resolved => closed


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker