This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: libstdc++/2830: incorrect inserter for std::string


The following reply was made to PR libstdc++/2830; it has been noted by GNATS.

From: "Simpson, Kenny" <Kenny.Simpson@gs.com>
To: 'Phil Edwards' <pedwards@disaster.jaj.com>, Kenny.Simpson@gs.com
Cc: gcc-gnats@gcc.gnu.org
Subject: RE: libstdc++/2830: incorrect inserter for std::string
Date: Tue, 15 May 2001 15:33:47 -0400

 #include <iostream> // for std::cout
 #include <string>
 
 int main()
 {
   std::string blanks( 3, '\0');
   std::string foo = "hello";
   foo += blanks;
   foo += "world\n";
   std::cout << bar;
   return 0;
 }
 
 This should print "hello\0\0\0world\n" to std::cout,
 but by sending bar.c_str(), all that gets sent is "hello".
 
 -Kenny
 
 -----Original Message-----
 From: Phil Edwards [mailto:pedwards@disaster.jaj.com]
 Sent: Tuesday, May 15, 2001 2:10 PM
 To: Kenny.Simpson@gs.com
 Cc: gcc-gnats@gcc.gnu.org
 Subject: Re: libstdc++/2830: incorrect inserter for std::string
 
 
 On Tue, May 15, 2001 at 07:07:27PM -0000, kenny.simpson@gs.com wrote:
 > At the end of bits/ostream.tcc I see:
 > 
 > // 21.3.7.8 basic_string::operator<<
 > ...
 >     { return (__out << __s.c_str()); }
 > 
 > first, shouldn't this be 21.3.7.9? as 21.3.7.8 describes swap.
 
 Yes, good catch.
 
 > second, this won't handle '\0's properly.
 
 Do you have a small testcase?
 
 
 Phil
 
 -- 
 pedwards at disaster dot jaj dot com  |  pme at sources dot redhat dot com
 devphil at several other less interesting addresses in various dot domains
 The gods do not protect fools.  Fools are protected by more capable fools.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]