Board index » cppbuilder » bug in std::map BCB5?

bug in std::map BCB5?


2006-09-05 11:01:57 PM
cppbuilder5
I have in my application a code like this (modified)
I have a map<Product*, int>theMap a vector<Product*>theVector and some
object, it doen't matter particulary, and in the following code:
someObject.someAttribute = theMap[ theVector[ someObject.someAttribute ] ];
originally someObject.someAttribute is equal to 1 and
theMap[ theVector[ someObject.someAttribute ] ] is equal to 3
after the line is executed, someObject.someAttribute is still 1.
I tried to reproduce the behavior with a small example, but it worked as
supposed (3 as final value) ... Any ideas?
--
Darío Alejandro Guzik (El Tío Borracho)
tioborracho.tripod.com
e-mail: XXXX@XXXXX.COM
ICQ : 8389493
 
 

Re:bug in std::map BCB5?

On Tue, 05 Sep 2006 12:01:57 -0300, Darío Alejandro Guzik wrote:
Quote
I tried to reproduce the behavior with a small example, but it worked as
supposed (3 as final value) ... Any ideas?
You really do need to create the small example. Description isn`t
enough.
--
Liz
Please check the newsgroup guidelines and general netiquette
info.borland.com/newsgroups/guide.html
info.borland.com/newsgroups/guide.html
info.borland.com/newsgroups/netiquette.html
 

Re:bug in std::map BCB5?

The problem is that I couldn't reproduce that behaviour in my small
examples...
Liz Albin wrote:
Quote
On Tue, 05 Sep 2006 12:01:57 -0300, Darío Alejandro Guzik wrote:

>I tried to reproduce the behavior with a small example, but it worked as
>supposed (3 as final value) ... Any ideas?

You really do need to create the small example. Description isn`t
enough.
--
Darío Alejandro Guzik (El Tío Borracho)
tioborracho.tripod.com
e-mail: XXXX@XXXXX.COM
ICQ : 8389493
 

{smallsort}

Re:bug in std::map BCB5?

Darío Alejandro Guzik < XXXX@XXXXX.COM >writes:
Quote
The problem is that I couldn't reproduce that behaviour in my small
examples...
Most likely, then, the bug is somewhere in your code, and not in the
map. Perhaps you're using an invalid index into the vector, or an
invald pointer value as the key. Perhaps you're hitting undefined
behavior.
Then again, maybe the way you're checking for this problem is actually
where the problem is. The values are properly updated, but when you
check to see if it was correctly updated you check the wrong object.
Or something like that.
Sorry, but vague guesses are all we can offer. Your question is
something we simply cannot answer without an actual piece of code that
we can run which is exhibiting the problem.
--
Chris (TeamB);
 

Re:bug in std::map BCB5?

Yes... I'm sorry the description is so vague. this problem was reported
to me by another programmer in my group and he told me "someone" said it
was a common problem with BCB, but I guess it isn't.
Sorry for the inconvenience
Chris Uzdavinis (TeamB) wrote:
Quote
Darío Alejandro Guzik < XXXX@XXXXX.COM >writes:

>The problem is that I couldn't reproduce that behaviour in my small
>examples...

Most likely, then, the bug is somewhere in your code, and not in the
map. Perhaps you're using an invalid index into the vector, or an
invald pointer value as the key. Perhaps you're hitting undefined
behavior.

Then again, maybe the way you're checking for this problem is actually
where the problem is. The values are properly updated, but when you
check to see if it was correctly updated you check the wrong object.
Or something like that.

Sorry, but vague guesses are all we can offer. Your question is
something we simply cannot answer without an actual piece of code that
we can run which is exhibiting the problem.

--
Darío Alejandro Guzik (El Tío Borracho)
tioborracho.tripod.com
e-mail: XXXX@XXXXX.COM
ICQ : 8389493
 

Re:bug in std::map BCB5?

On Tue, 05 Sep 2006 15:16:39 -0300, Darío Alejandro Guzik wrote:
Quote
Yes... I'm sorry the description is so vague. this problem was reported
to me by another programmer in my group and he told me "someone" said it
was a common problem with BCB, but I guess it isn't.
Actually, it /might/ be common, if you could come up with a smallish
(50 lines or less) program.
If you can`t -- well you know the drill -- start adding back code to
the little example til you get the problem again...
--
Liz
Please check the newsgroup guidelines and general netiquette
info.borland.com/newsgroups/guide.html
info.borland.com/newsgroups/guide.html
info.borland.com/newsgroups/netiquette.html
 

Re:bug in std::map BCB5?

I'll try.
One thing I think is worth mentioning es this:
In the original code, sometimes it failed with this code:
someObject.someAttribute = theMap[ theVector[ someObject.someAttribute ] ];
but worked fine modifying it to:
int temp = theMap[ theVector[ someObject.someAttribute ] ];
someObject.someAttribute = temp;
Don't know if it can lead to something. I'll keep trying to make my
short example fail
Thanks
Liz Albin wrote:
Quote
On Tue, 05 Sep 2006 15:16:39 -0300, Darío Alejandro Guzik wrote:

>Yes... I'm sorry the description is so vague. this problem was reported
>to me by another programmer in my group and he told me "someone" said it
>was a common problem with BCB, but I guess it isn't.

Actually, it /might/ be common, if you could come up with a smallish
(50 lines or less) program.

If you can`t -- well you know the drill -- start adding back code to
the little example til you get the problem again...
--
Darío Alejandro Guzik (El Tío Borracho)
tioborracho.tripod.com
e-mail: XXXX@XXXXX.COM
ICQ : 8389493
 

Re:bug in std::map BCB5?

On Wed, 06 Sep 2006 09:39:55 -0300, Darío Alejandro Guzik wrote:
Quote
In the original code, sometimes it failed with this code:

someObject.someAttribute = theMap[ theVector[ someObject.someAttribute ] ];

but worked fine modifying it to:

int temp = theMap[ theVector[ someObject.someAttribute ] ];
someObject.someAttribute = temp;
That might indicate that something is up with someObject -- or of
course that you're trashing something somewhere else that's only
showing up in someObject...
--
Liz
Please check the newsgroup guidelines and general netiquette
info.borland.com/newsgroups/guide.html
info.borland.com/newsgroups/guide.html
info.borland.com/newsgroups/netiquette.html