terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::substr
2012-07-17 10:50
591 查看
运行时报错:
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::substr
Aborted (core dumped)
内存读取越界。
解释1:for example:
const std::string sTest( "test" );
sTest.substr( 0, 10 );
will raise the same exception, since you ask 10 characters, but only 5 ( sTest.length()) ) are available.
调试过,正常运行,无报错。
解释2:
Chances are you did something like:
std::string s("foo");
s.substr(5,1); //the length of the string is 3, 5 is out of bounds
调试过,确实会报错,out_of_range
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::substr
Aborted (core dumped)
内存读取越界。
解释1:for example:
const std::string sTest( "test" );
sTest.substr( 0, 10 );
will raise the same exception, since you ask 10 characters, but only 5 ( sTest.length()) ) are available.
调试过,正常运行,无报错。
解释2:
Chances are you did something like:
std::string s("foo");
s.substr(5,1); //the length of the string is 3, 5 is out of bounds
调试过,确实会报错,out_of_range
相关文章推荐
- terminate called after throwing an instance of 'std::logic_error' [aidl] what(): basic_string
- terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct
- LeetCode terminate called after throwing an instance of 'std::logic_error' what(): basic_string::
- [aidl] terminate called after throwing an instance of 'std::logic_error' [aidl] what(): basic_string
- terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check
- 运行时错误: terminate called after throwing an instance of 'std::out_of_range'
- terminate called after throwing an instance of 'std::out_of_range'
- Tensorflow:terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
- ubuntu12.04连接服务器的时候出现错误“terminate called after throwing an instance of 'std::runtime_error' what(”
- terminate called after throwing an instance of 'std::string'
- 解决问题: terminate called after throwing an instance of 'std::runtime_error' what(): locale::facet::
- terminate called after throwing an instance of 'boost::thread_resource_error' what()
- terminate called after throwing an instance of 'std::regex_error'(C++11)
- Ubuntu16.04 terminate called after throwing an instance of 'std::logic_error'
- Deal with the error "terminate called after throwing an instance of 'std::bad_alloc'"
- terminate called after throwing an instance of 'std::length_error
- terminate called after throwing an instance of 'std::regex_error'
- 运行时错误:terminate called after throwing an instance of 'std::logic_error'
- terminate called after throwing an instance of 'std::bad_alloc
- linux下的C++编程错误(一):terminate called after throwing an instance of ‘std::ios_base::failure' wha