473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

STL set broken?

Hello,

I am using the std::set from the standard template
library, and it seems that it is broken. I've tried
both the MS version as well as the g++ version and I
get the same bug in both version.

As I fill the set with more and more ints, it suddenly
seems to reset itself. Here is some sample output of
the number of items in the set:

18317
30483
38315
43175
46061
47685
48539
48950
49125
49187
49203
49205
49205
18317 *** ???
30483
38315
43175

Is this a documented bug in stl? Is there something
I may be doing which breaks it? I am only using the
insert and size methods of a simple std::set<int> object.

- Andrew

--
http://www.headsupclub.com/aprock/
Nov 22 '05 #1
5 1549
A. Prock wrote:
Hello,

I am using the std::set from the standard template
library, and it seems that it is broken. I've tried
both the MS version as well as the g++ version and I
get the same bug in both version.

As I fill the set with more and more ints, it suddenly
seems to reset itself. Here is some sample output of
the number of items in the set:

[snip]

Is this a documented bug in stl? Is there something
I may be doing which breaks it? I am only using the
insert and size methods of a simple std::set<int> object.


The fact that your code breaks in the same way with two completely
different implementations of the STL indicates that almost certainly the
bug is in your code. Post the code.

john
Nov 22 '05 #2

"A. Prock" <pr*******@pokerstove.com> wrote in message
news:43**********************@spool.cs.wisc.edu...
| Hello,
|
| I am using the std::set from the standard template
| library, and it seems that it is broken. I've tried
| both the MS version as well as the g++ version and I
| get the same bug in both version.
|
| As I fill the set with more and more ints, it suddenly
| seems to reset itself. Here is some sample output of
| the number of items in the set:
|
| 18317
| 30483
| 38315
| 43175
| 46061
| 47685
| 48539
| 48950
| 49125
| 49187
| 49203
| 49205
| 49205
| 18317 *** ???
| 30483
| 38315
| 43175
|
| Is this a documented bug in stl? Is there something
| I may be doing which breaks it? I am only using the
| insert and size methods of a simple std::set<int> object.
|

Why should the std::set be broken if in fact the above code indicates
that the std::set container is correctly storing the dataset? Or are you
suggesting that the STL should prevent iterating through a container
more than once?

Have you even a clue how many folks have developed and tested the
various STL containers over the last 2 decades? And i've yet to find any
fundamental flaw in any of these yet.

Let me put it to you this way, if i pass a container by value, then add
elements to the original container, wouldn't it be in fact undefined
behaviour if the local container was to somehow include the new data
that is being added elsewhere?
Nov 22 '05 #3
A. Prock wrote:
Hello,

I am using the std::set from the standard template
library, and it seems that it is broken. I've tried
both the MS version as well as the g++ version and I
get the same bug in both version.
When something like that happens, you should always first assume that your
program contains the error, not the compiler or standard library. Remember
that those are often tested extensively. Of course, there are also bugs in
that software, but it is very unlikely that two separate implementations
contain the exact same bug _and_ that nobody noticed it yet.
As I fill the set with more and more ints, it suddenly
seems to reset itself. Here is some sample output of
the number of items in the set:

18317
30483
38315
43175
46061
47685
48539
48950
49125
49187
49203
49205
49205
18317 *** ???
30483
38315
43175

Is this a documented bug in stl?
What exactly is "this"? I mean, where is the code that produced that? Show
it. Maybe your code is erroneous.
Is there something I may be doing which breaks it?
How would anyone here know?
I am only using the insert and size methods of a simple std::set<int>
object.


And how was that output then produced?

Nov 22 '05 #4

"A. Prock" <pr*******@pokerstove.com> wrote in message
news:43**********************@spool.cs.wisc.edu...
Hello,

I am using the std::set from the standard template
library, and it seems that it is broken. I've tried
both the MS version as well as the g++ version and I
get the same bug in both version.

As I fill the set with more and more ints, it suddenly
seems to reset itself.
What do you mean 'reset'? Does its size become zero?
Here is some sample output of
the number of items in the set:

18317
30483
38315
43175
46061
47685
48539
48950
49125
49187
49203
49205
49205
18317 *** ???
30483
38315
43175
I'll take a wild guess here. Are you believing that
you should have more than one instance of the same
value in a 'std::set'? This container by definition
does not allow duplicates. If you want duplicates,
use 'std::multiset'.


Is this a documented bug in stl?
Is what a bug?
Is there something
I may be doing which breaks it? I am only using the
insert and size methods of a simple std::set<int> object.


No way to tell without seeing the exact code which produces
the 'problem.'

-Mike
Nov 22 '05 #5
According to John Harrison <jo*************@hotmail.com>:
The fact that your code breaks in the same way with two completely
different implementations of the STL indicates that almost certainly the
bug is in your code. Post the code.


Nothing like someone stating the obvious to lead
you directly to the solution. The code which created
sets was wrapped in a loop. So the sets were never
getting smaller (something which I was looking for
explicitly), they just were new instances.

Thanks,

- Andrew

--
http://www.headsupclub.com/aprock/
Nov 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Frank de Bot | last post by:
Hi, occasionaly I find in my apache logs that fastcgi had a broken pipe error with php running as fastcgi. the logs are like this: -- > (32)Broken pipe: > FastCGI: comm with server...
2
by: Nigel King | last post by:
I have a problem with the logging module. It reports a Broken Pipe error after outputing to the log file occasionally (5%). This does not appear to happen on Mac OSX using current finked python...
2
by: Dicky Cheng | last post by:
Hi, I am using .net remoting technology. I set up a .net remoting client and server in IIS. When the client calls the server, the server will run a long duration method (30-60seconds). I have a...
205
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
1
by: talyabn | last post by:
Hi, I'm trying to invoke the 'Broken Hyperlinks' option in the FrontPage application. The problem is that I get all the links in a given HTML page instead of getting only the broken links. ...
7
by: Jacob | last post by:
Has anybody else encountered a problem when running your asp.net applications off your localhost and having broken image links? The weird thing is, the links aren't really broken. The reference...
4
by: tt40 | last post by:
Anyone know how to prevent Access 2002 from automatically breaking all the incorrect joins in a query and then automatically saving the broken query? This is what I would call stupid design...
64
by: groups | last post by:
C# is an impressive language...but it seems to have one big limitation that, from a C++ background, seems unacceptable. Here's the problem: I have a third-party Document class. (This means I...
25
by: Norman Diamond | last post by:
I think the current version of _vsnwprintf_s is broken, in ordinary Windows. I'm not completely sure yet but it looks like this breakage is worse than previously known Windows CE breakage of...
8
by: Steven D'Aprano | last post by:
According to the Python docs, once an iterator raises StopIteration, it should continue to raise StopIteration forever. Iterators that fail to behave in this fashion are deemed to be "broken": ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.