bug in string::substr?

Benjamin Kosnik bkoz@cygnus.com
Thu Nov 18 17:16:00 GMT 1999


I cannot reproduce your crasher with either gcc-2.95.2 + libstdc++-v2 or
gcc-2.95.2 + libstdc++-v3. I get

> string x="abc";
> string y;
> 
> y=x.substr(1,0);

y is an empty string here, as this ctor is being used:

  template<typename _CharT, typename _Traits, typename _Alloc>
    basic_string<_CharT, _Traits, _Alloc>::
    basic_string(const basic_string& __str, size_type __pos, size_type __n)

The size of the string is zero, thus y == empty. 

Perhaps you had something else in mind?

-benjamin


More information about the Libstdc++ mailing list