This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
RE: libstdc++/2830: incorrect inserter for std::string
- To: nobody at gcc dot gnu dot org
- Subject: RE: libstdc++/2830: incorrect inserter for std::string
- From: "Simpson, Kenny" <Kenny dot Simpson at gs dot com>
- Date: 15 May 2001 19:36:01 -0000
- Cc: gcc-prs at gcc dot gnu dot org,
- Reply-To: "Simpson, Kenny" <Kenny dot Simpson at gs dot com>
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.