You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by pegasus2000 <pe...@email.it> on 2008/06/07 01:39:18 UTC

string concatenation trouble under Nanodesktop PSPE


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. 

-- 
View this message in context: http://www.nabble.com/string-concatenation-trouble-under-Nanodesktop-PSPE-tp17703255p17703255.html
Sent from the stdcxx-dev mailing list archive at Nabble.com.


RE: string concatenation trouble under Nanodesktop PSPE

Posted by Travis Vitek <Tr...@roguewave.com>.
 

pegasus2000 wrote:
>
>
>I've identified a problem in your library. 
>
>In the file:
>
>.\include\rw\_defs.h
>
>at row 455
>
>#if !defined(_RWSTD_NEW_CAPACITY_RATIO)
>   // using long doubles to eliminate bogus warnings on g++ 
>2.95.2/sparc
>   // (-W -O2/3 only): warning: overflow on truncation to integer
>#  define _RWSTD_NEW_CAPACITY_RATIO 1.618L
>#endif
>#if !defined(_RWSTD_MINIMUM_STRING_CAPACITY)
>#  define _RWSTD_MINIMUM_STRING_CAPACITY   128U
>#endif
>#if !defined(_RWSTD_STRING_CAPACITY_RATIO)
>#  define _RWSTD_STRING_CAPACITY_RATIO 1.618L
>#endif
>
>Well, some embedded processors have troubles
>with long double type. 
>
>This is the case of PSPE Emulated Processor. 
>So, I've modified the value to 1.618F and
>it works. 
>
>The port proceeds well. Each day I improve
>the compatibility.
>
>I've signalled this to you because I thought
>that it should be useful for you. 
>

Thanks!

>I suggest you to insert and #ifdef for 
>embedded processors. 
>

Actually, Farid made a change for 4.2.0 that eliminated the use of
floating point math for capacity calculations. You can find information
about that change in Jira and in Subversion

  http://issues.apache.org/jira/browse/STDCXX-226
  http://svn.apache.org/viewvc?view=rev&revision=605548

Travis

Re: string concatenation trouble under Nanodesktop PSPE

Posted by pegasus2000 <pe...@email.it>.

I've identified a problem in your library. 

In the file:

.\include\rw\_defs.h

at row 455

#if !defined(_RWSTD_NEW_CAPACITY_RATIO)
   // using long doubles to eliminate bogus warnings on g++ 2.95.2/sparc
   // (-W -O2/3 only): warning: overflow on truncation to integer
#  define _RWSTD_NEW_CAPACITY_RATIO 1.618L
#endif
#if !defined(_RWSTD_MINIMUM_STRING_CAPACITY)
#  define _RWSTD_MINIMUM_STRING_CAPACITY   128U
#endif
#if !defined(_RWSTD_STRING_CAPACITY_RATIO)
#  define _RWSTD_STRING_CAPACITY_RATIO 1.618L
#endif

Well, some embedded processors have troubles
with long double type. 

This is the case of PSPE Emulated Processor. 
So, I've modified the value to 1.618F and
it works. 

The port proceeds well. Each day I improve
the compatibility.

I've signalled this to you because I thought
that it should be useful for you. 

I suggest you to insert and #ifdef for 
embedded processors. 



-- 
View this message in context: http://www.nabble.com/string-concatenation-trouble-under-Nanodesktop-PSPE-tp17703255p17743059.html
Sent from the stdcxx-dev mailing list archive at Nabble.com.


Re: string concatenation trouble under Nanodesktop PSPE

Posted by Martin Sebor <se...@roguewave.com>.
Travis Vitek wrote:
>  
> 
> pegasus2000 wrote:
>> Travis Vitek-4 wrote:
>>> pegasus2000 wrote:
>>>>
>>>> Consider the following program:
>>>>
> 
> [...]
> 
>>>> 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.
>>> I have no way to tell where the program is crashing so I can't
>>> really give you much more information. All I can tell you is
>>> that most of the string functionality is implemented in
>>> `include/string' and `include/string.cc'. But you already knew
>>> that, right?
>>>
>>> BTW, it seems to me that it would make debugging much simpler
>>> if you had built a debug version of the libraries for the PC.
>>> Then you could take the code that fails on the PSP and step
>>> into it on the PC.
>>>
>>> Travis
>>>
>>>
>> Can you tell me how I can create a debug version of the library ?
>>
> 
> That is covered thoroughly in the README. Specifically sections 5 and
> 5.1, depending on which platform you are using.

Yes, it's a good idea to peruse the README. If after going
through it you still have questions or comments do let us
know -- we'll make an effort to enhance the text to cover
the topics that aren't sufficiently clear.

Martin

RE: string concatenation trouble under Nanodesktop PSPE

Posted by Travis Vitek <Tr...@roguewave.com>.
 

pegasus2000 wrote:
>
>Travis Vitek-4 wrote:
>> 
>> pegasus2000 wrote:
>>>
>>>
>>>Consider the following program:
>>>

[...]

>>>
>>>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.
>> 
>> I have no way to tell where the program is crashing so I can't
>> really give you much more information. All I can tell you is
>> that most of the string functionality is implemented in
>> `include/string' and `include/string.cc'. But you already knew
>> that, right?
>> 
>> BTW, it seems to me that it would make debugging much simpler
>> if you had built a debug version of the libraries for the PC.
>> Then you could take the code that fails on the PSP and step
>> into it on the PC.
>> 
>> Travis
>> 
>> 
>
>Can you tell me how I can create a debug version of the library ?
>

That is covered thoroughly in the README. Specifically sections 5 and
5.1, depending on which platform you are using.

Travis

RE: string concatenation trouble under Nanodesktop PSPE

Posted by pegasus2000 <pe...@email.it>.


Travis Vitek-4 wrote:
> 
>  
> 
> 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.
> 
> I have no way to tell where the program is crashing so I can't really
> give you much more information. All I can tell you is that most of the
> string functionality is implemented in `include/string' and
> `include/string.cc'. But you already knew that, right?
> 
> BTW, it seems to me that it would make debugging much simpler if you had
> built a debug version of the libraries for the PC. Then you could take
> the code that fails on the PSP and step into it on the PC.
> 
> Travis
> 
> 

Can you tell me how I can create a debug version of the library ?


-- 
View this message in context: http://www.nabble.com/string-concatenation-trouble-under-Nanodesktop-PSPE-tp17703255p17703762.html
Sent from the stdcxx-dev mailing list archive at Nabble.com.


RE: string concatenation trouble under Nanodesktop PSPE

Posted by Travis Vitek <Tr...@roguewave.com>.
 

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.

I have no way to tell where the program is crashing so I can't really
give you much more information. All I can tell you is that most of the
string functionality is implemented in `include/string' and
`include/string.cc'. But you already knew that, right?

BTW, it seems to me that it would make debugging much simpler if you had
built a debug version of the libraries for the PC. Then you could take
the code that fails on the PSP and step into it on the PC.

Travis

Re: string concatenation trouble under Nanodesktop PSPE

Posted by Martin Sebor <se...@roguewave.com>.
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