basic_string operator<< broken in for wchar_t in egcs 1.1.1

Baron Roberts baron@peanut.engr.sgi.com
Wed Feb 17 09:15:00 GMT 1999


BUG: STL basic_string operator<< broken in egcs 1.1.1 on RedHat Linux 5.2
-------------------------------------------------------------------------

The basic_string operator<< incorrectly assumes a single byte per
character. This breaks for a wchar_t string. The operator should
multiple the length of the string by the character size when providing
the stream size to the ostream write() method.

The fix effects the file:

	libstdc++/std/bastring.cc

ChangeLog entries and diff -cp follow.


libstdc++ ChangeLog
-------------------

Wed Feb 17 09:13:15 1999  Baron Roberts  <baron@sgi.com>

	* std/bastring.cc (operator<<): Stream size must be legnth
	of string multiplied by the size of the character type.


egcs-1.1.1/libstdc++/std/bastring.cc
------------------------------------

*** bastring.cc Wed Feb 17 09:13:15 1999
--- /usr/include/g++-2/std/bastring.cc  Wed Jan 27 11:59:37 1999
*************** template <class charT, class traits, cla
*** 467,473 ****
  ostream &
  operator<< (ostream &o, const basic_string <charT, traits, Allocator>& s)
  {
!   return o.write (s.data (), s.length () * sizeof(charT));
  }
  
  template <class charT, class traits, class Allocator>
--- 467,473 ----
  ostream &
  operator<< (ostream &o, const basic_string <charT, traits, Allocator>& s)
  {
!   return o.write (s.data (), s.length ());
  }
  
  template <class charT, class traits, class Allocator>


____________________________________________________

Baron Roberts                   Phone (650) 933-1653
http://www.sgi.com              mailto:baron@sgi.com

Application Technology Group, Silicon Graphics Inc.
____________________________________________________


More information about the Gcc-patches mailing list