0

Hello.

I tried to correct segmentation fault bug and I have found out a very strange thing imho: creating new instance with "new" returns address of already existing object, constructor is called and my old object is overwritten. I didn't delete my old object before. Could someone tell me what I might do wrong?
Thanks.

2
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by zipperhead
0

Probably because the program has trashed memory before the line with that new statement was executed. Uninitialized pointers, buffer overruns and writing beyond the bounds of arrays are the most common reasons.

0

Hmm... I use my own linked lists, put the code into infinite loop and it seems there are no memory leaks. Thanks anyway, going to analyze it one more time...

0

The problems I mentioned are not memory leaks. That is another problem. If you use <vector> or <list> you can avoid rolling your own links and all the problems they inherently have.

0

At last I made it... I had to do program to accomplish computations with graphs. I tried to use vectors and sets in the beginning but ended with some ugly errors 'cause I was not allowed to use vectors in non-const functions and couldn't create iterators in const functions or smth like that so I declined them. Now I found several sneaky mistakes and everything is fine now :]

By the way about those containers errors I mentioned above, is it some known issue? Just in case.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.