views:

2517

answers:

2

While running my program I get this Error:

terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::_S_create
Abort trap

I know that you can't do much without the code but I think that error is to deep in the code to copy all of it. Maybe I can figure it out if I understand what this error means. Is this a sign for an issue with reading or writing at the wrong memory address?

Is there something I can do to get more information about the problem from my program?

+4  A: 

It means you tried to create a string bigger than std::string::max_size().

http://msdn.microsoft.com/en-us/library/as4axahk(VS.80).aspx

A exception of type length_error Class is thrown when an operation produces a string with a length greater than the maximum size.

Kevin
Could that also mean that my string is not in memory anymore and I'm reading random junk from memory until the string is too big?
Janusz
You might create this situation accidentily by trying to create a string of size -1. String sizes are unsigned, so -1 is actually the largest possible unsigned integer.
MSalters
A: 

i got the same error when i was resizing my string i was trying to create substrings and resize it and i got that error, i was getting my string bigger but shorter, is it possible that during my resizing i forced the string to get lower than zero?

John