Index: string =================================================================== --- string (revision 611869) +++ string (working copy) @@ -266,7 +266,12 @@ void reserve (size_type = 0); void clear () { - _C_unlink (_C_nullref ()->data ()); + if (size_type (1) < size_type (_C_pref ()->_C_get_ref ())) + _C_unlink (_C_nullref ()->data ()); + else { + traits_type::assign (_C_data [0], value_type ()); + _C_pref ()->_C_size._C_size = 0; + } } bool empty () const { Index: string.cc =================================================================== --- string.cc (revision 611869) +++ string.cc (working copy) @@ -374,7 +374,7 @@ } else { // special case a substitution that leaves the string empty. - _C_unlink (_C_nullref ()->data ()); + clear (); } return *this; @@ -447,8 +447,8 @@ } } else { - // construct the empty string - _C_unlink (_C_nullref ()->data ()); + // special case a substitution that leaves the string empty. + clear (); } return *this; Index: istream.cc =================================================================== --- istream.cc (revision 611869) +++ istream.cc (working copy) @@ -877,7 +877,7 @@ if (__ipfx) { - __str.erase (); + __str.clear (); // carefuly handle arithmetic overflow _SizeT __n = __str.max_size ();