This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ Static String Causes Segmentation Fault


Ben Atkinson wrote:
Thanks for the response, Ian. With an eye toward correcting the problem
in my source code, does C++ make any guarantees about global
constructors in the same source?
A more robust scheme is to create a function (or static member function) that returns the
static string, and using this function to get the string...


class XXX {
...
static std:string& mystring() { static std::string foo = "whatever"; return foo; }


...
};


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]