warning: deprecated conversion from string constant to 'char*'|

Pages: 12
There's nothing wrong with that copy ctor @ Azagaros.

The problem must be elsewhere.

Also, for what it's worth, there's no way that having const pointers could be doing anything that causes a segfault. You probably have some heap corruption somewhere that's causing this.

Can you post the entire CString class? If it's too large for a forum post, maybe throw it up on pastebin or something.
Last edited on
I noticed problem on every std library call the class made.

The entire class is there, with working notes.
http://pastebin.com/siF48D56

Most of this class is printed in several books. It has also been an exercise in figuring out what's in the standard library and what's not.

The call I make to this is that i note the exception looked like this, however the class that this is in is Dynamically allocated Class.

1
2
3

CString tmpString = (CString&)AnotherString; // the cast isn't there in the actual code.


I am wondering if Mingw is giving me problems. So I might load this up on a Unix system.
Your CString::Find has a buffer overflow. The while should test for *pString.

And you've got around a million memory leaks (one for each function that creates a pTmp and doesn't delete it).

Also, some of your functions have strange unusual interfaces (almost all "CString&" - paramter should be "const CString&", but we already covered that ;). Substring usually is already zero based). I won't say anything about the performance of CString, except maybe: "strlen is not very fast and strcat calls to strlen".

Other than that, I could only see a buffer overflow in Format when a parameter exceeds the unchecked buffer. If you don't use Format with large parameter strings in your example, then the tip with the heap corruption is quite good. (Means: The problem is complete elsewhere).


To find heap corruptions: Simplify your application by removing more and more things until the error does not occur anymore and then look carefully at the last step you did before it suddenly where working. (Or create a new toy-application where you add stuff until the error suddenly occurs).
Topic archived. No new replies allowed.
Pages: 12