What is the meaning of this C++ Error std::length_error

删除回忆录丶 提交于 2019-12-05 09:45:50

问题


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 this error is too 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?


回答1:


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

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




回答2:


I know this is a old question but I just ran into the same issue. Using Linux with gcc.

Disassembling the function showed a lot of jumps in the code, where the exception was thrown, which shouldn't be there. In the end, a Clean Build resolved the issue for me.




回答3:


This is an error in debug mode with VS2005. When I change it to release mode, everything works.

Well, the vc debug runtime causes this, that's all.



来源:https://stackoverflow.com/questions/1183700/what-is-the-meaning-of-this-c-error-stdlength-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!