incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: string concatenation trouble under Nanodesktop PSPE
Date Mon, 09 Jun 2008 09:14:23 GMT
pegasus2000 wrote:
> 
> Consider the following program:
> 
> #include <nanodesktop.h>
> 
> // of the string class which is part of the
> // Standard Template Library
> #include <string>
> #include <cstdlib>
> #include <iostream>
> 
> using namespace std;
> 
> // concat - return the concatenation of two strings
> string concat(string s1, string s2)
> {
>    return s1 + s2;
> }
> 
> 
> int main(int argc, char* pArgs[])
> {
>     ndInitSystem ();
>     
>     // create a string that is the sum of two smaller strings
>     cout << "string1 + string2 = "
>     << concat("string1 ", "string2")
>     << endl;
> }
> 
> The program crashes when executes s1+s2. 
> 
> I need the stack trace at that point, so I can check in which routine the
> trouble
> is localized. 
> 

Is the empty string body (the string::_C_null_ref static data
member) is properly initialized (i.e., zeroed out)? Also, when
debugging problems like this you might find it easier to isolate
their source if you use stdio instead of iostreams.

Martin


Mime
View raw message