Re: [SLUG] C++ Strings Library

From: Ronan Heffernan (ronan.heffernan@shawus.com)
Date: Wed Apr 24 2002 - 03:09:02 EDT


Paul M Foster wrote:
> This is probably a long shot. I'm coding a database application in C++,
> and using the g++ version 3 string library. This is a Red Hat 7.2
> system. I'm getting a segfault at a certain point, and using gdb to
> trace into that point. The code is trying to instantiate a string from a
> char array. It's going through the string library, checking to see if
> enough space has been allocated, etc. etc. At some point within that
> code, it attempts to allocate more space for the string (24 chars long).
> And at that point, it segfaults. There is plenty of memory on this
> machine, and I have very little running.
>
> Anyone heard of this type of problem with this version of the g++ string
> library?
>
> Paul

No, it sounds like a standard operation. I always cast the char array
to a "(const char *)" when passing it in. Can you post a meaningful
code snippet and/or backtrace?

There is one situation that will almost always cause such a segfault
(don't be insulted): if your string object is *itself* not allocated.

Something like:
string *str;
str="this is a test";

--ronan



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:31:06 EDT