Here is proposed patch to fix STDCXX-170 issue: ChangeLog: * string.cc (replace): Copy data to temporary string object if data is a part of the internal string buffer. Index: string.cc =================================================================== --- string.cc (revision 556830) +++ string.cc (working copy) @@ -516,6 +516,15 @@ _RWSTD_ASSERT_RANGE (__first1, __last1); _RWSTD_ASSERT_RANGE (__first2, __last2); + if ( !(__first2 == __last2) + && __s._C_data <= &*__first2 + && __s._C_data + __s.size () > &*__first2) { + + // __first2 points to internal string buffer + return __s.replace (__first1, __last1, + basic_string (__first2, __last2)); + } + // use a (probably) faster algorithm if possible if (_STD::__is_bidirectional_iterator(_RWSTD_ITERATOR_CATEGORY(_InputIter, __last2)))
Farid.